Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Migration from version 1.0 to 2.0
There are some breaking changes in the 2.0.0 release. Here's a summary and instructions for migrating your application.
Event.value now contains the event value instead being a function that returns the event value. Similarly
Event.is* methods and the
Event.hasValue method have been converted to boolean properties. So, if you use
flatMapEvent or any other method where you have to handle
Event objects, convert your method calls to property references. For instance:
event.isError() becomes just
EventStreams are always asynchronous
You can no longer rely on
f synchronously. Hopefully you didn't before this either.
It's no longer possible to create an
EventStream that responds synchronously. If you try to create one using
fromBinder or other constructors, the resulting stream will automatically convert your replies to asynchronous.
Property initial/current value is still delivered synchronously, so you can use
Bacon.constant(..) to deliver a constant value synchronously.
Property.flatMap* methods now return a
Property instead of an
EventStream. This shouldn't be an issue and if you have
p.flatMap(..).toProperty() you can now simply omit the
If you have
p.flatMap(..).toProperty(initValue) you can use
p.flatMap(..).startWith(initValue) instead for supplying a initial value.
If you use a library that requires Bacon.js 0.7 or 1.0, the library needs to change. The suggested way is to change the library thus that it either
- Works with both 1.0 and 2.0 versions and has Bacon.js as a
peerDependencywith a suitable version range. See Baret for example. Some libraries may need to include a little hack to support both 1.0 and 2.0 versions of Bacon, because the
Eventobject methods have been converted to properties.
- Has separate versions for 1.0 and 2.0. It's still very much advisable to use
peerDependenciesto avoid the situation of having two distinct instances of Bacon in your application.