Closed jeroencranendonk-wf closed 9 years ago
Assuming that is unintended behavior, anyway :) I know that it caused issues for me, although it could be that I am using Immstruct in unexpected ways.
Hi! Sorry for the late response. I was thinking of this while writing it. I thought it made sense to share queued change and batch all change, but it might make more sense to be able to not "share state" between instances.
If you create multiple instances of Structure, event handlers registered for 'next-animation-frame' are only called for the first instance for which
queuedChange
was false.If multiple Structure instances are modified within a frame, this leads to event handlers not being called when expected.
I see two possible solutions:
queuedChange
per instance, rather than as a module global, or:requestAnimationFrameEmitter
add to a list of [emitter, newStructure, oldData, keyPath] entries every time it is called, and emit 'next-animation-frame' on every item in that list.