Releases: lostpebble/pullstate
1.21.0 - React 17, cache break and batch()
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.
1.20.1 React Native Debugger fix
Using registerInDevtools()
should now work with the Redux React Native debugger implementation. Thanks to @wnz99 for championing this change.
1.20.0 - Async Error Payloads
Minor Release. Thanks to @ultd for bringing up the suggestion and working on these changes.
- Allow the passing of an
errorPayload
to the end result of an Async Action.
// response from inside an async action
return errorResult(["NOT_FOUND"], "User was not found", errorPayload)
This allows you to pass an additional object which you define, in order to communicate more information / data about what went wrong.
If an async action has finished resolving, and is in an error state (isFailure
represents this when making use of AsyncAction.use()
), then the error payload will be defined (if you have passed something in for it):
const getUserAction = GetUserAsyncAction.use({ userId: "asd" });
if (getUserAction.isFailure) {
getUserAction.errorPayload // <- Would be defined if you are making use of it
}
1.19.0 - Async fixes and useDefer
(Unfortunately I skipped 1.18.0 by mistake...)
Some internal fixes for Async Actiosn and a new deferred way to run and watch action state
AsyncAction.useDefer()
You can now now use Async Actions with a method called useDefer()
. This method allows you to defer the execution of an action in a later trigger further down inside your component or its children. What's really nice about this is that you don't need to know the arguments beforehand, as you do with the regular action use. This is great for listening to tasks and showing state in a parent component, which is triggered further down in a child component (such as button click on "Update User" or some kind of form submit).
const deferredAction = UpdateUser.useDefer();
// ... somewhere later or in another component
<button onClick={() => defferedAction.execute(newUserData)}>Update User</button>
This simplifies a lot of scenarios with Async Actions.
1.17.0 - Local Component Stores
Added useLocalStore()
function for allowing the use of pullstate stores to replace regular React.useState()
in some scenarios, as local state within your components (non-global state stores).
As extras, you can also call MyStore.useLocalCopyInitial()
or MyStore.useLocalCopySnapshot()
on any of your stores to create a local component-lifetime copy of those stores- either set to whatever your stores state was initially or a snapshot of what it is at this moment, respectively.
Added UMD export
Can be accessed from https://unpkg.com/[email protected]/dist/pullstate.umd.js in your plain browser HTML projects.
1.16.0
Fix to caching of running actions, which disallows double running of actions when used in both a useBeckon()
and run()
situation at the same time (while respectCache
is true).
1.15.3 - Draft<S> type update
Fixes #48
Adds Draft<S>
wrapper around the draft state in an update function, allowing updates on readonly
types inside a store.
1.15.2
Added the ability to "namespace" the devtools integration. This prevents clashes when working on multiple apps at the same time. Passable as an option in the second argument to registerInDevtools()
Redux Devtools Integration
Thanks to @lukasmoellerch for helping to bring about these changes.
Added integration with Redux Devtools. Make use of registerInDevtools(Stores)
to use it. Argument is an object of { [storeName: string]: Store }
- which will register your stores instanced according to the name provided.