Skip to content

Conversation

@32bitkid
Copy link
Contributor

Here is an implementation that enhances the existing combine method to accept objects as well as arrays:

const a = Kefir.sequentially(1000, [1,2,3]), b = Kefir.constant(4);
Kefir.combine({a,b}).log();
// { a: 1, b: 4 }
// { a: 2, b: 4 }
// { a: 3, b: 4 }

Given key conflicts between active and passive observables, it will prefer active ones:

const a = Kefir.sequentially(1000, [1,2,3]), _a = Kefir.constant(4);
Kefir.combine({a}, {a: _a}).log();
// { a: 1 }
// { a: 2 }
// { a: 3 }

Mismatched (array/object) active and passive collections throw an exception.

Kefir.combine({a}, [b]); // error

After thinking about it, I think overloading combine() feels like a more predictable interface for new users and improves code readability. However, I'm open to switch it to its own method (it wouldn't take much abstraction from its current form to do that).

I'll work on updating the documentation if this looks like a good approach/direction.

@rpominov
Copy link
Member

Overall everything looks good. I'm happy with how API looks externally, and I only may have some comments on implementation detail when I get a chance to take a closer look.

@aindlq
Copy link

aindlq commented Dec 28, 2016

Do you still have plans to merge this in? It can be very convenient to use this feature with Mapped Types from the latest Typescript, see microsoft/TypeScript#12114

@rpominov
Copy link
Member

Yeah, sorry, I've forgot to give more feedback.

Everything looks good so far, @32bitkid! If you'd like to finish this up, that would be awesome.

@32bitkid 32bitkid force-pushed the combine-supports-objects branch from 6376726 to cc1549e Compare December 28, 2016 20:57
@32bitkid
Copy link
Contributor Author

@rpominov I've been meaning to wrap this up, as well. I took a stab at some documentation, let me know if you need anything else from me to get this merged in.

@rpominov
Copy link
Member

Thank you very much for all the work, everything looks great! I'll merge this and release a new version tomorrow.

@rpominov
Copy link
Member

Sorry, couldn't do it today. Very busy at work these days. I'll get to this tomorrow or at weekend.

@rpominov rpominov merged commit 0671f0c into kefirjs:master Dec 31, 2016
rpominov added a commit that referenced this pull request Dec 31, 2016
* master:
  cleanup repository after release
  3.7.0
  update changelog
  #143 Make Kefir.combine() also accept sources as objects (#225)
  fix RxJS url (#231)
@rpominov
Copy link
Member

Merged and released.
Thank you again, and happy 2017!

@32bitkid 32bitkid deleted the combine-supports-objects branch December 31, 2016 20:17
@32bitkid
Copy link
Contributor Author

32bitkid commented Jan 1, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants