This file contains hidden or 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
[[[NSNotificationCenter.defaultCenter | |
rac_addObserverForName:NSApplicationDidBecomeActiveNotification object:nil] | |
takeUntil:self.rac_willDeallocSignal] | |
subscribeNext:^(NSNotification *notification) { | |
NSLog(@"got ur note bro: %@", notification); | |
}]; | |
// some other shit |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>DVTConsoleDebuggerInputTextColor</key> | |
<string>0.770437 0.783913 0.778299 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>Inconsolata - 13.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>0.770437 0.783913 0.778299 1</string> |
This file contains hidden or 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 NSArray *databaseObjects; | |
__block NSArray *fileContents; | |
NSOperationQueue *backgroundQueue = [[NSOperationQueue alloc] init]; | |
NSBlockOperation *operation1 = [NSBlockOperation blockOperationWithBlock:^{ | |
databaseObjects = [databaseClient fetchObjectsMatchingPredicate:predicate]; | |
}]; | |
NSBlockOperation *operation2 = [NSBlockOperation blockOperationWithBlock:^{ | |
NSMutableArray *filesInProgress = [NSMutableArray array]; |
This file contains hidden or 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
// The basics | |
[[self.connection fetch:@"the-answer"] subscribeNext:^(NSNumber *x) { | |
NSLog(@"The answer is %@", x); | |
}]; | |
[[self.connection writeObject:@42 forKey:@"the-answer"] subscribeCompleted:^{ | |
NSLog(@"Wrote it."); | |
}]; | |
// Signal for changes to the object at a key |
This file contains hidden or 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
RAC(self.someView.hidden) = [RACAbleWithStart(self.someArray) map:^(NSArray *x) { | |
return x.count == 0; | |
}]; |
This file contains hidden or 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
RAC(view, hidden) = [arraySignal map:^(NSArray *x) { | |
return x.count == 0; | |
}]; |
This file contains hidden or 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
[[[[[[[[[[self.searchTextField | |
rac_textSignal] | |
filter:^BOOL(NSString *value) { | |
return value.length > 2; | |
}] | |
doNext:^(NSString *x) { | |
NSLog(@"[%@] Text Changed: %@", [NSThread currentThread], x); | |
}] | |
throttle: .6] | |
doNext:^(id x) { |
This file contains hidden or 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
@implementation NSEvent (RACSignals) | |
+ (id<RACSignal>)rac_signalForEventsMatchingMask:(NSEventMask)eventMask { | |
return [RACSignal createSignal:^(id<RACSubscriber> subscriber) { | |
id monitor = [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *event) { | |
[subscriber sendNext:event]; | |
return event; | |
}]; | |
return [RACDisposable disposableWithBlock:^{ |
This file contains hidden or 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
self.startButton.rac_command = [RACCommand command]; | |
self.stopButton.rac_command = [RACCommand command]; | |
self.resetButton.rac_command = [RACCommand command]; | |
static const CGFloat interval = 0.01; | |
__unsafe_unretained id weakSelf = self; | |
// Signal id -> Signal Signal Number | |
// Map each click of the start button to a signal that fires at our interval | |
// and stops when the stop button's clicked. | |
id<RACSignal> start = [self.startButton.rac_command map:^(id _) { |
This file contains hidden or 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
self.startButton.rac_command = [RACCommand command]; | |
self.stopButton.rac_command = [RACCommand command]; | |
__unsafe_unretained id weakSelf = self; | |
id<RACSignal> tick = [[[[self.startButton.rac_command | |
map:^(id _) { | |
RTAFirstView *strongSelf = weakSelf; | |
// Map each start button click to a new signal that fires every second | |
// and stops when the stop button is clicked. | |
return [[RACSignal interval:1] takeUntil:strongSelf.stopButton.rac_command]; |