Open TrySound opened 6 years ago
Sorry for the delay in getting to this. transact
and transaction
allow doing nested transactions. I'm not sure that's a use case that anyone cares about though, so feel free to merge this.
But what nested transactions allow to do?
const x = atom('root')
transact(() => {
x.set('in top transaction')
try {
transact(() => {
x.set('in bottom transaction')
throw new Error('whoops')
})
} catch (_) {}
x.get() === 'in top transaction' // true
})
With atomically
, .get()
would still be in bottom transaction
, since atomically
doesn't create a new transaction context.
Now we have a lot of ways to do transaction. I'd like to figure out is there a use case in transact/transaction functions over atomic/atomically?
/cc @ds300 @andreypopp