mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Enhancement: Monitors from unsafe transactions should get notified of changes #59
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tmspzz on GitHub (May 20, 2016).
Current State:
Monitors created via
transaction.monitor...for transaction of typeUnsafeDataTransactiondo not get notified of changes until the transaction is committed.However, they are notified if
transaction.internalContext.save()is calledProposal:
Have the option in a
UnsafeDataTransactionto be notified upon context saves. Maybe in the fashion ontransaction.flushesChangesImmediately = true@JohnEstropia commented on GitHub (May 20, 2016):
I can't think of a reasonable timing for an auto-flush without any trigger from some function call.
It will be too heavy if each property assignment triggers one flush.
The simplest I can think is to require a call to
transaction.flush()when the changes are ready to be propagated to observers.Another solution is to wrap all changes in closures:
@tmspzz commented on GitHub (May 20, 2016):
I like the closure approach. However the scenario for that usage sometime looks like:
I would give the option for both.
@tmspzz commented on GitHub (May 23, 2016):
Was thinking maybe the first case can be made prettier:
@JohnEstropia commented on GitHub (May 23, 2016):
In the end I stuck the name
flush, I hope you won't mind:It matches CoreStore's SQL-ish naming (begin, commit, etc) and there's really no need to give separate names for the no-closure and the closure versions.
See:
c15afcb381