A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k
stars
56
forks
source link
Provide a warning when attempting to update the state of an outdated freezer object #97
Hi - I really like this library, thanks for building it! As I'm getting up the learning curve I'd love to help make some of the things I found difficult easier for other users. One such instance is this one:
var store = new Freezer({
a: {x: 1, y: 2, z: [0, 1, 2] },
b: [ 5, 6, 7 , { m: 1, n: 2 } ],
c: 'Hola',
d: null // It is possible to store whatever
});
store.on('update', function( update ){
console.log('I was updated: ' + update.a.z[3]);
});
var data = store.get();
var updated = data.a.z.push( 100 );
var willNotUpdateStore = data.set('x', "I will not update the freezer!");
console.log(store.get()); // Will not include `x` key.
Is there ever a use case where you would want to update data in this example a second time? Currently freezer fails silently and I suggest making this raise a warning or even an exception to make it easier for people to understand that you cannot update the same store twice...you have to update the new node or call store.get().
Does this make sense? I apologize in advance if I'm misunderstanding why the current functionality works the way it does. I'd be happy to submit a PR if that's helpful.
Hi - I really like this library, thanks for building it! As I'm getting up the learning curve I'd love to help make some of the things I found difficult easier for other users. One such instance is this one:
Is there ever a use case where you would want to update
data
in this example a second time? Currently freezer fails silently and I suggest making this raise a warning or even an exception to make it easier for people to understand that you cannot update the same store twice...you have to update the new node or callstore.get()
.Does this make sense? I apologize in advance if I'm misunderstanding why the current functionality works the way it does. I'd be happy to submit a PR if that's helpful.