Add combineOnLeft and combineOnRight #130

raimohanska opened this Issue Mar 26, 2013 · 5 comments


None yet

3 participants


It's a little-known fact that you can do an equivalent of "combineOnRight" by calling property1.sampledBy(property2, f). I think it would make sense to add more explicit combineOnLeft and combineOnRight for combining Properties in such a way that the result is only updated when the left/right property is updated. Implementation would be trivial:

Property.prototype.combineOnRight = Property.prototype.sampledBy
Property.prototype.combineOnLeft = (other) -> other.combineOnRight(this)

Any thoughts?


They can obviously be created pretty easily using the existing combinators, so it might not be necessary to include them in Bacon's core. Are there obvious use-cases for both combineOnLeft and combineOnRight?

… actually, I don't suppose there would be any obvious use-cases for having both, since one is a trivial argument-flip of the other. Still, there may be uses that are clearer when written in one order rather than another, so it's an open question.

baconjs member

I'm guessting the implementation for combineOnLeft would be

combineOnLeft = (other, f) -> other.combineOnRight(this, flip(f)); //also flip function argument

Bu yeah I've implemented this myself several times already, wouldn't mind having this in the library.


Your guess seems correct :) There are really just convenience functions but surely would make code much easier to read than using sampledBy.

So, PR will be merged.


Closing this for now due to lack of interest.

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