Skip to content
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

Added 'previous' and 'diff' modules #67

Merged
merged 2 commits into from
Oct 25, 2015
Merged

Added 'previous' and 'diff' modules #67

merged 2 commits into from
Oct 25, 2015

Conversation

jwoudenberg
Copy link
Contributor

I regularly want to create a stream that responds to changes in values in another stream. To help with that, I added two modules that I think might be interesting to others.

flyd-previous takes a stream and returns a stream that's always one value behind the original stream.

flyd-diff uses flyd-previous to provide a variant of map, in which the mapper function is called with the previous and new value of the stream.

Additionally, I took the liberty of adding a basic .editorconfig file, which I think is a great help for contributors, but if it's not liked just tell me and I'll take it out again :).

I'm looking forward to all feedback!

@paldepind
Copy link
Owner

This looks very good! These are nice modules in my opinion 👍

I have one concern though. From looking at the source code it appears that a stream created with previous will always initially emit an undefined when its source stream receives its first value? That does not seem ideal to me.

@jwoudenberg
Copy link
Contributor Author

Thanks! Hmm, I see your point. It would make more sense if it starts streaming once the second value arrives, right? I'll change that.

@paldepind
Copy link
Owner

Yes, exactly :)

@jwoudenberg
Copy link
Contributor Author

I changed the previous module to start streaming once the source stream receives its second value. Of course the diff function exhibits the same behavior.

Let me know if you have any more feedback :).

@paldepind
Copy link
Owner

Really great! Thank you for this contribution 😄

paldepind added a commit that referenced this pull request Oct 25, 2015
Added 'previous' and 'diff' modules
@paldepind paldepind merged commit e1eb313 into paldepind:master Oct 25, 2015
@jwoudenberg
Copy link
Contributor Author

Thanks!

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.

None yet

2 participants