horizon
horizon copied to clipboard
Resubscribing to a watch() Observable causes duplicated data
Server version: 1.1.3 Client version: 1.1.3
Unsubscribing and then resubscribing the same watch() Observable will cause records to be added to the collection even when they are already present.
var t = horizon('tasks');
t.store({title: 'test'}).subscribe(function (stored) {
var id = stored.id;
var watch = t.findAll(id).watch();
var sub = watch.subscribe(function (r) {
console.log(r);
});
setTimeout(function () {
sub.unsubscribe();
sub = watch.subscribe(function (r) {
console.log(r);
});
}, 1000);
});
Hi @tomdegoede could you try out the 2.0.0 beta? We changed how the watches work, they should be reference counting their subscribers now
I'm adding this to the next release. We at the very least should have a test for this behavior