You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PCDCollection requires separate operations to add PCDs, and then set their folder. This is not only awkward to code, but it means there are intermediate states which shouldn't ever exist (where the new PCDs are in the root folder). The use of the emitter to notify listeners means that external code has a good chance of finding out about those intermediate states, including inside of internal code in PCDCollection such as applying feed actions, or merging.
I was considering some refactoring to avoid the extra emitter calls, but I think it would be cleaner to make folder an argument to addPCD() instead.
The text was updated successfully, but these errors were encountered:
Alternatively: restrict all changes to the PCD collection to action handlers, where no changes are committed until the action handler calls update. In the long run it's going to be a lot easier to make our action handlers atomic than to make every method on PCDCollection atomic.
The case for not caring either way would be that React only cares about updates at the next animation frame - that is, when the current event loop has finished - so the emitter firing mulitple times in the current event loop is fine in practice.
I'm fascinated that we have opposite assumptions about where in the stack it's easiest to do deal with atomicity. I suspect that's driven by the different ways concurrency works in JavaScript from what I'm used to in multithreaded languages. Controlling concurrency at the app level so you don't have to at other levels is appealing, though we should talk more about how to deal with (or eliminate) state modifications which aren't inside of a dispatch action. At the app level that sometimes happens when the app needs to wait for the result of an operation. I'm also not sure if background sync wants to keep being tied to the app's action dispatch, though that's a larger design topic for later.
PCDCollection requires separate operations to add PCDs, and then set their folder. This is not only awkward to code, but it means there are intermediate states which shouldn't ever exist (where the new PCDs are in the root folder). The use of the emitter to notify listeners means that external code has a good chance of finding out about those intermediate states, including inside of internal code in PCDCollection such as applying feed actions, or merging.
I was considering some refactoring to avoid the extra emitter calls, but I think it would be cleaner to make folder an argument to addPCD() instead.
The text was updated successfully, but these errors were encountered: