diff options
Diffstat (limited to 'src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m')
-rw-r--r-- | src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m new file mode 100644 index 0000000000..9a53531b12 --- /dev/null +++ b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m @@ -0,0 +1,28 @@ +#import "GRXNSBlockEnumerator.h" + +@implementation GRXNSBlockEnumerator { + id (^_block)(); +} + +- (instancetype)init { + return [self initWithValueSupplier:nil]; +} + +- (instancetype)initWithValueSupplier:(id (^)())block { + if ((self = [super init])) { + _block = block; + } + return self; +} + +- (id)nextObject { + if (!_block) { + return nil; + } + id value = _block(); + if (!value) { + _block = nil; + } + return value; +} +@end |