I have something like the following:
const cUpdate =
sUpdate
.snapshot(cStuff, doStuff)
.orElse(sCommit.map(() => S.Nothing)) //This will automatically mark the update as completed
.hold(S.Nothing)
const cCommit =
sCommit
.snapshot(cUpdate, commitStuff)) //if cUpdate is a Nothing, it's a noop
.hold(S.Nothing);
The idea is two different streams - sUpdate
and sCommit
. sCommit
essentially commits or flushes the changes that were staged during sUpdate.snapshot()
However, once those changes were committed, there's no reason for it to re-commit. The line:
.orElse(sCommit.map(() => S.Nothing))
is therefore intended to mark the update as flushed once it's committed.
Do I have the ordering right? Is cUpdate
guaranteed to be that S.Nothing
after commitStuff
runs? i.e. after the changes have been flushed?
I believe I can more explicitly do that via something like const cFlushed = sCommit.map(() => S.Nothing).hold(S.Nothing)
and then change sCommit.snapshot
to snapshot3
and get the status there... I think this might be somehow more guaranteed since holds are delayed - but I'm not sure
(edit: I tried the hold/snapshot thing and it didn't work... from casual observation, the first sample code I posted seems to be fine - but it's a bit hard to tell without unit tests if I'm missing an event)