baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript

Home Page:https://baconjs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bacon.js 2.0

raimohanska opened this issue · comments

I'm trying to come up with a version 2.0 in the near future, with at least the following changes:

#700 Remove lazy evaluation of event values
#706 Make Bacon.once and friends asynchronous
#708 Use rollup to build everything from ES6 modules
#711 Force asyncness of all streams created with any of the stream constructors

EDIT: all four PRs merged into the 2.0 branch.

Development in branch 2.0.

Known breaking changes:

  1. Event.value now contains the event value instead being a function that returns the event value
  2. You can no longer rely on Bacon.once(...).onValue(f) calling f synchronously
  3. Property.flatMap* methods now return a Property instead of an EventStream
  4. No longer possible to create an EventStream that response synchrnously. If you try to create one using fromBinder or other constructors, the resulting stream will automatically convert your replies to asynchronous.

Known affected libraries:

  • baret updated to 1.1.0 which supports both Bacon 1.0 and 2.0
  • bacon.atom updated to 5.0.5 (just bacon.js version changed here)
  • bacon.combines updated to 0.1.3 (just bacon.js version changed here)
  • baret.util updated to 0.3.2 (just bacon.js version changed here)
  • Bacon.matchers updated to 0.4.2 (just bacon.js version changed here)

Try the development version by using the following line in your package.json:

    "baconjs": "baconjs/bacon.js#2.0",

For 2.0 I would like to keep compatibility with Bacon.matchers. Since I find it is nice syntactic sugar.

"Removing lazy evaluation of event values" is fine I guess since it seems to remove a complex logic in Bacon.js I haven't noticed yet. Thus I too hope that this will not break my code.

The bacon.matchers library should work as before, as there doesn't seem to be anything special in the source code. The package.json needs an update though. I suggest we apply version ranges, devDependencies and peerDependecies there to make it compatible with different versions of Bacon.

UPDATE: bacon.matchers 0.4.2 supports Bacon.js up to version 2 using peerDependencies.

My colleages suggested this:

  1. Guarantee that EventStreams emit asynchronously regardless of how they were created.

This would apply to streams created using fromESObservable, fromCallback and friends.

This would require a mechanism in fromBinder or the EventStream constructor to ensure that events are not emitted synchronously as a respose to subscription.

Properties are still allowed to emit their current value syncrhonously as there's no downside to that.

Pls vote up/down for this. I'm cautiously supportive myself

EDIT: #711 merged

Would be great if folks tested their applications against the 2.0 branch (instructions above).

2.0 branch looks good to me now. Changes merged in, tests pass, there's a more modern command line interface based on package.json scripts. Grunt's gone.

I think everything's good to go except for the "4th amendment" above. Anyone wanna PR on this?

Ok, there are some things that are not quite golden yet.

  1. Custom builds can be made with scripts/dist [parts] but testing individual parts is broken.
  2. Browser tests haven't been run on anything except on my OSX laptop in Chrome and Firefox. I do have on open-source automation account for BrowserStack some work is needed to enable automatic browser tests.

Also performance is affected. When I last compared to master, combine etc performance looked similar, but passthrough and eventstream creation was much slower. I guess it's the new extra checks speaking.

I don't see performance degradation as a blocker for 2.0.0 release though, as this a breaking change anyways. Performance can be tweaked later.

Closing the Issue. Will handle in Pull Request #709