Added in a batch()
function which allows you to run multiple Store.update()
inside of it, and have all the updates be batched at the same time to your App. Updates in batch()
must be synchronous (can't be an async function). This allows defining cross-store updates in a more performant way, when these changes are made outside of the React event structures (regular button clicks etc.- these are batched by React by default).
Async Actions now also accept an extra option when being consumed:
const getImagesAction = GetImages.use({ tag: "green" }, { cacheBreak: true });
cacheBreak
can be a boolean or a function which returns a boolean value (the function signature is the same as the regular cacheBreakHook
that you can set when creating Async Actions).
This allows you to more finely control the cache breaking per a component- the next time a component is mounted, it will check this value and decide if we need to run the action anew.
This can also go hand-in-hand with another option: holdPrevious: true
- which will hold the previously result of the Async Action (if its available) while the action runs again on the cache break.
Pullstate now also defines that it supports the peer dependency of react
for versions ^17.0.0
as well- this prevents NPM errors in the newer version, which is more strict about peer dependencies.