KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Trying to follow the best practices of ReactiveCocoa to update my UI on the hour, every hour. This is what I've got: NSDateComponents *components = [[[NSCalendar sharedCalendar] calendar] components:NSMinuteCalendarUnit fromDate:[NSDate date]]; // Generalization, I know (not every hour has 60 minutes, but bear with me). NSInteger minutesToNextHour = 60 - components.minute; RACSubject *updateEventSignal = [RACSubject subject]; [updateEventSignal subscribeNext:^(NSDate *now) { // Update some UI }]; [[[RACSignal interval:(60 * minutesToNextHour)] take:1] subscribeNext:^(id x) { [updateEventSignal sendNext:x]; [[RACSignal interval:3600] subscribeNext:^(id x) { [updateEventSignal sendNext:x]; }]; }]; This has some obvious flaws: manual subscription and sending, and it just "feels wrong." Any ideas on how to make this more "reactive"?
Tags (comma-separated)
Save Edits
Cancel