Updated ddp.js to 2.1.0.
No changes. Only published to fix the latest tag on npm.
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.1the library was distributed as a bundle for client-side consumption, and could be installed via bower or npm. It was not possible though torequirevia browserify or webpack,require-ing it only worked in node.In
2.0.0the 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
AsteroidclassIn
0.6.1the module exported a class,Asteroid.In
2.0.0the module exports acreateClassfunction, which is used to create theAsteroidclass.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
AsteroidinstancesThe signature of the
Asteroidclass 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.1thecallandapplymethods returned an object with two properties:resultandupdated.resultwas a promise to the method invocation result.updatedwas a promise which resolved when the server sent anupdatedmessage for the invocation.In
2.0.0both 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 likeasteroidInstance.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.1thesubscribemethod returned an object containing:- a
stopmethod, which could be called to terminate the subscription - a
readyproperty, a promise which resolved when the server marked the subscription as ready
In
2.0.0thesubscribemethod returns an object containing:- an
idproperty, which can be used to terminate the subscription by passing it to theunsubscribemethod - an
onmethod (the object is an event emitter), which can be used to register a handler for theready,error(and soon also thestopped) events
The change was made to allow a finer-grained management of subscriptions.
- a
-
Managing collections
0.6.1handled collections.2.0.0simply 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-sreactiveQuery-s were a feature of collections. As such, they have also been dropped in2.0.0.
Unless you're certain you need 1.0.0, skip it and just use 2.0.0
We began the rewrite that led to 2.0.0 sometime in summer 2015. Development
took place on the 1.0.0-rewrite branch. Unfortunately we never got to the
point of actually releasing 1.0.0, and changes staled in the 1.0.0-rewrite
branch for several months. Some of our projects migrated to 1.0.0, installing
it directly from the branch.
Then 2.0.0 came along and brought with it some minor braking changes (it's a
bit of an oxymoron, but...) that we couldn't push to 1.0.0-rewrite. So we
froze the branch, published 1.0.0 from there and right after published
2.0.0.
Sorry for the mess. Pretend 1.0.0 never existed. If you can't because - like
us - you're in some way dependent on it, we hope to have made all we can to
keep it available. If not, let us know and we'll help you out.
Basically 0.6.1 with two pull-requests merged in.