The magic of LiveSet stop whenever I call the method twice !!!
Hi,
I tried to use the google groups to solve my issue but I didn't have any helpful answer.,, it is simply the LiveSet not updated even that the events is received... this odd behaviour start when I call the following code twice
set=new LiveSet(result,changes) $scope.list=set.toLiveArray()
the $scope.list in the second call is updated with the new result, however, the $scope.list not notified whenever new event occur...
https://groups.google.com/forum/#!searchin/loopbackjs/liveset/loopbackjs/NrtbSZwWiQo/RYcod9N9AwAJ
I really appreciate any kind of help,
Thanks in advance
A simple example app that reproduces the problem would be helpful and would speed up a fix.
You should only execute that code once though.
Thanks for you help, I really appreciate your effort.
In my case I have to do execute the code more than one time to get different result based on date,
here you will find very simple example app that demonstrate the problem.
- here is the loopback app https://github.com/yasser-kfupm/lesc
- here is the angular app that uses angular-live-set https://github.com/yasser-kfupm/frontEnd
in our simple example, all the data are on the following dates :
10/16/2015 10/17/2015 10/18/2015 10/19/2015 10/20/2015
in case I should never execute that code more than one time, what can I do solve my problem, I just need to have different data in the same liveSet.
Again thanks for help...
This is also happening to me. I have to explicitely call _applyChange so the liveArray is updated:
var src = new EventSource(url);
var cs = createChangeStream(src);
Mymodel.find().$promise.then(function (data) {
$scope.liveSet = new LiveSet(data, cs);
$scope.liveSet.changes.on('data', function (change) {
$scope.liveSet._applyChange(change);
});
$scope.myLiveArray = $scope.liveSet.toLiveArray();
});
It seems what happens is that the changeStream never emits the "readable" event, only "data" :` live-set.js:
changes.on('readable', function() {
var change = changes.read();
if(change) {
set._applyChange(change);
}
});
I have a very similar issue. I needed backwards compatibility with a key-press page refresh that re-queries or when filters change it re-queries, but I wanted the live updates too. The complicating factor, live sets do not support filters yet.
One thing I had to do was delete the EventListener / EventSource when re-creating it, when the filter changed, otherwise, I ran into a max EventListener error when multiple updates were occurring.
I did this with EventSrcName.close();
I wrote custom code to apply the changes in the changes.on('data'...
This was to handle some of the filter stuff that was missing. I didn't try the one guy's server side solution yet, because it seemed a bit complicated still.
Filter issue with server side workaround solution mentioned:
https://github.com/strongloop/angular-live-set/issues/11
I've also bumped into this issue. It showed up for me in the following scenario. I created a LiveSet for synchronizing an array in scope, but I also attempted to monitor the changed using changed.on('data', cb), so that I could orchestrate other update in the UI. When I added the "on data" handler, the changes.on('readable... line of code in LiveSet is never called.
I'm not sure if that is normal behavior for a stream, but its seems odd. When I see that sort of on handler I expect that I can register any number of callbacks.
I could open another stream, but there are obvious downsides to that, including using up a connection and duplicating data transmissions. I may try patching in a callback around _applyChange to notify my when a change has arrived.
Ugh... so we aren't getting the readable event ...but the data event...? That sounds like a compatability mode related bug, but I'm not quite sure. I saw a patch that uses data instead of readable ...but I don't think that should be required.
I wonder if pulling in the latest browserified streams.js would fixe the readable issue.
When I added the "on data" handler, the changes.on('readable... line of code in LiveSet is never called.
Hmm... I think this might be the issue. The ReadableStream class allows one or the other style readable or data. I'm tempted to ditch the Streams 3 readable event for the consistent data event.
@ritch I have a pull request open for this
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.