sends multiple observers through the connect function, which means draggable.state is written to repeatedly, which means you can't rely on state.read() to give you the state from the last move.
Potential solutions
Only write to a property if its value hasn't changed, and allow multiple connections
Create a new variable called prevState that remembers the last value from state in connect's closure, so writes to state always have the same value, and make observers dedupe() state if they care about uniqueness.
Create a _multicast() operator, that serves the same observer-pooling use as _remember() without lastValue
Perhaps there could be a MemorylessSubject that serves this purpose, and instead of returning a new MotionObservable, _multicast() returns MotionMemorylessSubject.
MotionSubject would then be MemorylessSubject + memory
_remember() would return a MotionSubject
MotionMemorylessSubject would also be useful for distributing cancelation signals between gestural interactions - perhaps it should be called MotionChannel?
Alternatively, can just take a rememberLastValue flag in both _remember and IndefiniteSubject and use that to condition observer.next(lastValue). _remember is then sugar for _multicast(true)
Problem
sends multiple observers through the
connect
function, which meansdraggable.state
is written to repeatedly, which means you can't rely onstate.read()
to give you the state from the last move.Potential solutions
prevState
that remembers the last value from state inconnect
's closure, so writes to state always have the same value, and make observersdedupe()
state if they care about uniqueness._multicast()
operator, that serves the same observer-pooling use as_remember()
withoutlastValue
MemorylessSubject
that serves this purpose, and instead of returning a newMotionObservable
,_multicast()
returnsMotionMemorylessSubject
.MotionSubject
would then beMemorylessSubject
+ memory_remember()
would return aMotionSubject
MotionMemorylessSubject
would also be useful for distributing cancelation signals between gestural interactions - perhaps it should be calledMotionChannel
?rememberLastValue
flag in both_remember
andIndefiniteSubject
and use that to conditionobserver.next(lastValue)
._remember
is then sugar for_multicast(true)