-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve transaction support for data changes #2
Comments
hi @zerkalica Thanks for ping me with the problem. It should trigger update just once, but the result should be as you said: [ 0, 'a', 'b', 2, 3, 4] I will have a look at it tomorrow. It doesn't work like immutable's Anyways, it should be great to have a way of applying multiple changes at once, like a database transaction isn't it? Something like; data.arr.transaction()
.push( 5 ) // [0,1,2,3,4,5]
.pop() // [0,1,2,3,4]
.unshift( 'a' ) // ['a',0,1,2,3,4]
.shift() // [0,1,2,3,4]
.splice( 1, 1, 'a', 'b') // [ 0, 'a', 'b', 2, 3, 4]
.run()
; What do you think? |
Looks good, but will it work with hashes, not only array? var store = new Freezer({
root: {
a: {aa: {c: 1}},
b: {bb: {cc: 321}},
arr: [1, 2, 3, 4]
}
});
store.get().root.transaction()
.a.set({aa: {c: 123}}
.b.set({bb: {cc: 321}}
.arr.push(5)
.run() |
We can work on it. Any ideas on how to?
|
I have released a new version fixing the parameter of the 'update' event. Transaction support will come in a future release. Cheers, |
Transactions are now working in freezer 0.5 https://github.com/arqex/freezer#batch-updates I hope you like them. |
Is analog Immutable.withMutations for atomic data changes?
In this example only first array change will trigger update listener:
The text was updated successfully, but these errors were encountered: