Changelog
2.0.3 (October 7, 2016)
Fixed a bug on the subscription base mixin when restart the subscription.
Changelog
2.0.0 (February 16, 2016)
The library has undergone a major rewrite. As such it's drastically different
from 0.6.1
. The API changed, hopefully for the best. Its scope also changed a
bit, so some features that were in 0.6.1
have been dropped in 2.0.0
. Of
course the reverse is also true.
Installing the library
In 0.6.1
the library was distributed as a bundle for client-side
consumption, and could be installed via bower or npm. It was not possible
though to require
via browserify or webpack, require
-ing it only
worked in node.
In 2.0.0
the library is distributed as an npm module. It's not distributed
as a bundle though, so you can't download it and include it as a script in
your html. If publishing it as a bundle (through npm and/or bower) is needed,
please open an issue and I'll add support for it.
The change was made to support require
-ing the library in client-side code.
The bundle is not distributed just because we haven't had the time to do so.
Obtaining the Asteroid
class
In 0.6.1
the module exported a class, Asteroid
.
In 2.0.0
the module exports a createClass
function, which is used to
create the Asteroid
class.
The change was made to allow adding functionalities to the class via mixins (see docs).
// 0.6.1
const Asteroid = require("asteroid");
const asteroid = new Asteroid(/* ... */);
// 2.0.0
const createClass = require("asteroid").createClass;
const Asteroid = createClass();
const asteroid = new Asteroid(/* ... */);
Creating Asteroid
instances
The signature of the Asteroid
class constructor changed.
The change was made to allow to specify options which mixins might need.
// 0.6.1
const asteroid = new Asteroid(host, useSsl, interceptorFunction);
// 2.0.0
// The `optionsObject` now takes whatever options needed by the used mixins.
const asteroid = new Asteroid(optionsObject);
Calling methods
In 0.6.1
the call
and apply
methods returned an object with two
properties: result
and updated
. result
was a promise to the method
invocation result. updated
was a promise which resolved when the server
sent an updated
message for the invocation.
In 2.0.0
both methods return directly a promise to the invocation result.
The library does not currently offer a way to listen for the updated event (it
can be done by doing something like
asteroidInstance.ddp.on("updated", handler)
).
The change was made to simplify method calls (it seemed more idiomatic for a js library to have this API).
// 0.6.1
asteroid.call("myMethod", 1, 2, 3).result.then(ret => {
console.log(ret);
});
// 2.0.0
asteroid.call("myMethod", 1, 2, 3).then(ret => {
console.log(ret);
});
Subscribing to publications
In 0.6.1
the subscribe
method returned an object containing:
stop
method, which could be called to terminate the subscriptionready
property, a promise which resolved when the server marked the
subscription as readyIn 2.0.0
the subscribe
method returns an object containing:
id
property, which can be used to terminate the subscription by passing
it to the unsubscribe
methodon
method (the object is an event emitter), which can be used to
register a handler for the ready
, error
(and soon also the stopped
)
eventsThe change was made to allow a finer-grained management of subscriptions.
Managing collections
0.6.1
handled collections.
2.0.0
simply doesn't. Handling collections is delegated to third party
mixins, such as asteroid-immutable-collections-mixin.
The change was made because in many projects we found ourselves not using Asteroid's collections, but rather re-implementing them in some other way (e.g. as immutable maps). To avoid wasting cpu time and memory storing them in Asteroid directly, we preferred to leave managing them to external mixins. Admittedly, there is currently no mixin that replicates the old behaviour. If you developed one or plan to do so, be sure to let us know and we'll list it in the mixins section in the README.
Using reactiveQuery
-s
reactiveQuery
-s were a feature of collections. As such, they have also been
dropped in 2.0.0
.
Changelog
1.0.0 (February 16, 2016)
Unless you're certain you need 1.0.0
, skip it and just use 2.0.0