A streamable interface for Pubnub. This library also works nicely with crudlet, and other crudlet adapters.
Example
var pubnub = ;var crud = ; var pubStream = ; // tail all remote messages; // publish a remote message to the world;
db pubnub(options[, reject])
Creates a new pubnub streamer.
options
subscribeKey
- your pubnub subscription keypublishKey
- your pubnub publish keychannel
- (optional) the channel to subscribe to
reject
- set of commands to reject - default is[load]
var pubStream = ; // does not get broadcasted;
db.addChannel(channel)
adds a new channel to subscribe to.
pubStream;pubStream
stream.Readable db(operationName, options)
Publishes a new operation to pubnub.
;;
stream.Readable db(tail, filter)
Tails a remote operation. This is your subscription function.
db({ name: "tail" }).on("data", function(operation) {
});
Or you can do something like synchronizing databases between clients:
var crud = ;var loki = ;var pubnub = ; var pubdb = ; var db = crud; // listen for local operations on lokidb - pass to pubnub; // listen for remote operations on pubnub - pass to lokidb; // stored in loki & synchronized across clients;