Sunday 19 March 2017

deepstream list subscribing to data

is it possible in deepstream to subscribe to data using a list? it appears that changes to the data does not trip the subscribe() function, only something like an addEntry() appears to affect the list subscription.

const   deepstream      = require('deepstream.io-client-js')            ;
const   util            = require('util')                               ;

const   client  = deepstream('localhost:6020').login();

var obj_1       =       { 'sequelizeName':'Mark', 'sequelizeAddr':'123 Elm Lane'    , 'sequelizeId':'1111'};
var obj_2       =       { 'sequelizeName':'Lori', 'sequelizeAddr':'948 Maple Street'    , 'sequelizeId':'2222'};

const rec_1     = client.record.getRecord('obj_one');
const rec_2     = client.record.getRecord('obj_two');

rec_1.set(obj_1);
rec_2.set(obj_2);

var listTest    =       client.record.getList('listTest');

listTest.setEntries(    ['obj_one' ,'obj_two' ] );

listTest.subscribe( (result) => {
        console.log('LIST SUBSCRIBE: ' + util.inspect(result));
})

setTimeout( () =>       {
        obj_1.sequelizeAddr = '321 New Address';
        rec_1.set(obj_1); // how can this change show up in the list subscribe?
}, 2000 );

I have been encouraged to try a new approach using lists, but I am unclear how to subscribe to changes in the data itself using a list, except to somehow have some sort of "generic" or "global" subscribe, which i am not sure is even possible.

Or is there some way I can subscribe using an anonymous record?



via edwardsmarkf

No comments:

Post a Comment