New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add +combineLatest: #44
Add +combineLatest: #44
Conversation
… the reduce defaults to the identity function.
This is looking good. Do you mind adding a unit test as well? |
I was hoping you'd ask. ;) I'm in the midst of downloading OS X 10.8 so I On Mon, Aug 27, 2012 at 6:08 PM, Justin Spahr-Summers <
|
Does it not work on 10.7? |
Not for me. Tried twiddling Base SDK and compiler settings but no go. |
changed the behavior slightly so that it will yield multiple successive tuples of 'latest' values from source subscribables. this change required re-initializing the lastValues pointer, which was previously being used as a synchronization gate; a new gate object is introduced to synchronize calls to onNext.
I have added a commit with tests. |
@@ -406,7 +407,7 @@ + (RACSubscribable *)combineLatest:(NSArray *)subscribables reduce:(id (^)(RACTu | |||
for(id<RACSubscribable> o in subscribables) { | |||
[orderedValues addObject:[lastValues objectForKey:[NSString stringWithFormat:@"%p", o]]]; | |||
} | |||
|
|||
lastValues = [NSMutableDictionary dictionaryWithCapacity:subscribables.count]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just use [lastValues removeAllObjects]
, which would remove any need for the nextGate
variable used here.
Almost there. Added an additional note. |
…ar the dictionary rather than re-assign the pointer with a newly allocated dictionary
Good catch. Thanks! |
…t want to assume the compiler will set them to nil!
🤘✨⚡🚢 |
I just snuck one more minor commit in—could you take a look at it? |
@bvanderveen I appreciate the thoroughness; however, object variables are default-initialized to nil under ARC:
|
True. Figured it was better to be explicit, but it's your call. :) |
Any removal of boilerplate is 👍 to me, so I'd like to leave it out. |
Thanks for the merge! |
Add Carthage/Build to .gitignore
+combineLatest:
is the same as-combineLatest:reduce:
, where the reduce defaults to the identity function.Per github/ReactiveCocoa#43.