Action batching in MobX 6 when handling asynchronous retry loops
0 reputation · 04 Oct 2022, 19:30 UTC
State Consistency in Async Retries
MobX 6 batches state changes made inside an action into a single notification, reducing unnecessary re-renders. When an asynchronous operation is retried, each attempt may trigger its own state update, potentially breaking the batching guarantee and causing duplicate writes.
Given the strict mode and action wrapper behavior, how can a retry loop be structured so that only the final successful state change triggers a reaction, without duplicating intermediate notifications? What patterns preserve action batching across asynchronous boundaries? Is there a way to defer or collapse multiple updates into a single action while preserving retry logic?