I have a related problem extending from here. What's a good approach to then clear the queue based on when another stream fires?
In my particular use case that other stream firing does two things: process the current queue and clears it. So far it seems fine but I'm not entirely certain if the timings are as I assume, e.g. if it will always process before clearing and always clear before the next processing.
Here's some code sample (in Typescript, simplified with some of the annotations removed) where the
s prefix means
Left/Right/Maybe/Nothing/Either are all from Sanctuary. The different event sources are just meant to illustrate the concept of the actual use case and
InputEvent is a common struct that they all supply.
sUpdate is the Stream that causes that queue to be processed/cleared - and my question can therefore be restated as such: is
process(data) guaranteed to happen after the
accum() which happened in the same
const sUpdate:Stream<any>; //<--- pre-existing
const cInputs:Cell<Array<InputEvent>> =
.map(() => Nothing)
(clearEvent, inputEvent) => Left(inputEvent.value)
(input, total) =>
: input.isLeft ? [input.value] : total.concat(input.value));
.snapshot(cInputs, (updateData, inputEvents) => mergeData(updateData, inputEvents))