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

Generalize EventStream methods to Property #23

Closed
raimohanska opened this issue Oct 21, 2012 · 6 comments
Closed

Generalize EventStream methods to Property #23

raimohanska opened this issue Oct 21, 2012 · 6 comments

Comments

@raimohanska
Copy link
Contributor

  • flatMap
  • switch
  • startWith : for injecting an Init value, same as toProperty(initValue)
  • mapEnd
  • scan (in progress, issue 17)

Possibly add

  • toEventStream: makes an event stream that's like p.changes().startWith(p.currentValue)
@mtkopone
Copy link
Contributor

Nom nom... Yes please. Here's what we currently have:

Bacon.Property.prototype.switch = function(fn) {
  var changes = this.changes()
  return this.flatMap(function(value) {
    return fn(value).takeUntil(changes)
  })
}
Bacon.Property.prototype.flatMap = function() {
  return Bacon.EventStream.prototype.flatMap.apply(this, arguments)
}
Bacon.Property.prototype.takeUntil = function() {
  return Bacon.EventStream.prototype.takeUntil.apply(this, arguments)
}

Not entirely sure that it works tho...

@raimohanska
Copy link
Contributor Author

  • takeUntil is already implemented in the Observable class.
  • flatMap can be simply moved to Observable
  • switch could be as above, or like @toEventStream().switch(..).

@raimohanska
Copy link
Contributor Author

Who wants to do this? Most work is writing tests, probably. Docs should be updated as well.

@raimohanska
Copy link
Contributor Author

Done with flatMap: 3957ea7

@raimohanska
Copy link
Contributor Author

Done with switch, toEventStream: d307010

@raimohanska
Copy link
Contributor Author

Readme updated in a6573d6

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

No branches or pull requests

2 participants