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

extra emitter methods to use with .withHandler and .fromBinder #51

Closed
mhelvens opened this issue Feb 13, 2015 · 3 comments
Closed

extra emitter methods to use with .withHandler and .fromBinder #51

mhelvens opened this issue Feb 13, 2015 · 3 comments

Comments

@mhelvens
Copy link
Contributor

It would be quite useful, for example, in a .withHandler handler, to be able to pass an event directly, and / or to plug a stream into an emitter:

stream.withHandler(function (emitter, event) {
    if (event.type === 'end') {
        emitter.plug(Kefir.later(1000, 1)); // a 'last minute concat'
    } else {
        emitter.send(event); // just pass the event
    }
})

Without this, some tedious branching-code would need to be written.

@rpominov
Copy link
Member

Yep, something like .emitEvent in emitter object makes sense. As well as in emitter stream, at least for consistency. Will add it soon.

@mhelvens
Copy link
Contributor Author

How about .plug? (It does seem like Event and Pool and Bus might all bleed together a bit, though I understand they are technically different concepts.)

@rpominov
Copy link
Member

Not sure about this, not very easy to add, and will probably make .withHandler (and other methods where emitter object are used) a bit heavier.

You can use .flatMap for this. And, if you need to handle all kind of events, something like this:

stream.withHandler(function(event, emitter) {
  emitter.emit(event); // emitting event object as value, so all events available in next step
}).flatMap(function(event) { ... })

rpominov added a commit that referenced this issue Feb 15, 2015
* master:
  cleanup repository after release
  1.1.0
  improve release scripts
  more on loops in .repeat
  note about infinite loops with .repeat
  add Kefir.repeat() method
  fix a bug in .merge and .zip
  add .emitEvent (fix #51)
  update deps
  check emitter to be instance of Emitter (in test spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants