Created
December 6, 2012 23:22
-
-
Save hallski/4229370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__block __typeof(self) weakSelf = self; | |
__block int tick = 0; | |
id<RACSignal> timer = [[[[RACSignal interval:1.0] startWithTrigger:self.startButton.rac_command] takeUntil:self.stopButton.rac_command] repeat]; | |
[timer subscribeNext:^(id x) { | |
weakSelf.timerLabel.stringValue = [NSString stringWithFormat:@"%d", tick++]; | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id<RACSignal>)startWithTrigger:(id<RACSignal>)signalTrigger | |
{ | |
return [RACSignal createSignal:^(id<RACSubscriber> subscriber) { | |
__block RACDisposable *selfDisposable = nil; | |
__block RACDisposable *triggerDisposable = [signalTrigger subscribe:[RACSubscriber subscriberWithNext:^(id x) { | |
selfDisposable = [self subscribeNext:^(id x2) { | |
[subscriber sendNext:x2]; | |
} error:^(NSError *error) { | |
[subscriber sendError:error]; | |
} completed:^{ | |
[subscriber sendCompleted]; | |
}]; | |
} error:^(NSError *error) { | |
} completed:^{ | |
}]]; | |
return [RACDisposable disposableWithBlock:^{ | |
[triggerDisposable dispose]; | |
[selfDisposable dispose]; | |
}]; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment