This repository was archived by the owner on Jan 4, 2023. It is now read-only.
fix(deps): update dependency easy-peasy to v5 #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
2.6.6->5.1.0Release Notes
ctrlplusb/easy-peasy
v5.1.0Compare Source
Minor Changes
Patches
connectto Hooks ⚡: #652Credits
Huge thanks to @jmyrland, @avramch, @no-stack-dub-sack, @yethranayeh, and @troglodytto for helping!
v5.0.5Compare Source
Patches
2fab9a2c63555cCredits
Huge thanks to @jmyrland for helping!
v5.0.4Compare Source
Patches
ea98660444396f86405638fce26bf24ab2568fdfffCredits
Huge thanks to @fbieler, @mfbx9da4, @yakovlevyuri, @w3bdesign, and @GavinRay97 for helping!
v5.0.3Compare Source
## Patches
v5.0.2Compare Source
Patches
772f1b5v5.0.1Compare Source
Patches
v5.0.0Compare Source
Finally! The next major version of Easy Peasy has landed. It's been a long time
coming, and we are hopeful that the need for a new major release will be a long
way off.
This last year has been a challenging one for me on a personal level, so I want
to extend my thanks to the patience that the community has shown in me getting
this release together. I am aware that the docs still do not reflect the full
updated API reflection of v4. I humbly apologise for this and do promise that
parity will be achieved. This release already includes a lot of ground work
around revamping the docs. I plan to pump a lot more hours into getting the docs
into a much more improved and useful structre.
I've become aware of a critical security issue with the version of Immer
currently utilised within Easy Peasy <= v4. For that purpose I am issuing this
release earlier than I anticipated.
Whilst this is a major release the breaking changes are very minimal. So I
sincerely hope that your upgrade will be as fluid as it can be.
Breaking Changes
memohelper. You'll need to bring your own memoization library,for e.g. memoizerific.
Changes
Upgraded to Immer v8 🎉
Fixes to support IE11!
You will need to use our new import at the entry of your application to patch
Proxy.
In addition to this if you use Map or Set in your state then you will need
this additional import at the entry of your application.
Improved the bundle size! The Gzip bundle is back down to approximately 10kb.
Fixed issue with computed properties throwing errors when being accessed in
certain scopes
Improved the module exports to improve tree shaking capability
Added various bundle type support to the package.json, e.g. "module".
Fixed bugs when rehydrating persisted state
v4.0.2Compare Source
Patches
a72aa7ev4.0.1Compare Source
Patches
b39dd4eCloses #565
v4.0.0Compare Source
The long wait is over.
v4 has arrived! 🎉
This release includes an insane amount of improvements and fixes, with an ironing over some of the APIs and features that were introduced in v3.
This release will also include a completely overhauled website. This work is still in progress and is likely to continue even after the v4 release. It's a lot of work and I don't want it to be the sole reason for us holding back on the v4 release.
Unfortunately there are breaking changes, however, I expect the breaking changes will only impact a subset of our userbase that are using the more advanced features of Easy Peasy.
Breaking Change
Replaced
createComponentStorewith auseLocalStorehookThe API for
createComponentStorewas a verbose and limited.Taking learnings from it we have replaced it with a new API; namely
useLocalStore.Please see the API documentation for more information.
Persist API rewrite
The persist API received a huge overhaul to the point that it should essentially be considered a rewrite.
We suggest that you read the updated docs and update your implementations accordingly.
Some notable changes include:
Upgraded to
immer@7We used to managed a forked version of Immer as it previously did not support computed properties. This is no longer the case! We now rely on the native Immer package.
A side effect of this is that you may experience browser support issues for browsers that do not support support Proxy.
If you require your application to work on such environments (e.g. Internet Explorer 11 or some versions of React Native on Android) then please ensure that you import and execute the
enableES5feature from Immer.Moved internal
redux-thunkbinding to grant user defined middleware higher priorityThis will allow you to influence thunks prior to their execution. For advanced cases.
This likely will have zero impact on anyone, but given the nature of the change we are marking it as breaking.
Thunk action states, error handling, and listener behaviour updates
Easy Peasy will no longer catch any errors within your thunks and dispatch a "failed" state action. If you wish to explicitly mark your thunk as failed, so that an action listener can respond to it accordingly then you need to use the new
failhelper that is provided to thunks.Error handling is now explicitly your responsibility.
The actions that are dispatch to represent thunk states have been updated. Taking the example above here are the possible action types that will be dispatched and visible in the redux dev tools:
@thunk.myThunk(start)Dispatched at the start of a thunk execution.
@thunk.myThunk(success)Dispatched when a thunk has completed - i.e. with no uncaught errors occurring.
@thunk.myThunk(fail)Dispatched if the
failhelper was called. In this case the@thunk.myThunk(success)would not have been dispatched.Listeners (actionOn and thunkOn) will now by default only respond to the "success" event of a thunk. If you wish to handle the "fail" events then you will need to explicitly resolve them.
New Features
unstable_effectOnAllows you to declare an effect within your model which will execute every time the targeted state changes.
Two arguments are provided to unstable_effectOn; namely the
stateResolversand thehandler. ThestateResolversare an array of functions which should resolve the target state that should be tracked. When the tracked state changes thehandlerfunction is executed.The
handlercan be asynchronous or synchronous. It receives the store actions, achangeobject containing theprevvalues for the targeted state and thecurrentvalues as well as theactionthat caused the change in state. It additionally receives ahelperargument allowing you to access the store state etc.The
handleradditionally allows you to return a dispose function, which will be executed prior to the next execution of thehandler. This can be useful in performing things like API call cancellation etc.Context stores now allow you to override injections at runtime
Simply pass your injections as a prop to the
Providerfor the context store.See the updated docs for more information.
Fixes
Computed properties are now immutable bound to state
Previously if you executed a computed property it would always resolve against the latest version of the store state. Now it will operate against the state at the moment of time it was pulled out from.
In doing this we also addressed a strange case where you may get an error for invalid computed property access.
Internals rewritten to utilize incoming model definitions immutably
This will address any issues where you may have been providing model definitions to different stores.
TypeScript
Loads of fixes and improvements to the typings
Phew. Too many to mention. Just take our word for it. Tons of nitty issues have been addressed.
Added support for generics in models
Previously if you defined a model containing generic state, like below, TypeScript would break within your actions.
Unfortunately we were unable to directly resolve the case of generic properties due to current limitations with the TypeScript type system. We created a StackOverflow question which details the problem.
In a gist; the issue is that Easy Peasy's underlying
StateandActiontypes map over the user provider model types in order to filter down to types that represent state and actions respectively. However, when defining a generic state, TypeScript assumes that the generic state intersects with types that are trying to be filtered out of each case. Therefore the filtering ends up always removing your generic state.To resolve the case of generic state we have introduce a new API helper. Any time you wish to have a generic state value within your model, simply wrap it with the
Generictype, and then assigned the associated value within the model instance using thegenerichelper.Note how you only need to use the helper at the point of defining the initial value of the generic model state. Within your actions and anywhere you consume the state you would treat the value as the underlying generic value (i.e. a
numberin the example).Removed the limit on TypeScript model depth
Previously, if you had a model more than 6 levels deep, in terms of object structure, the TypeScript mapping wouldn't work as expected. This is no longer the case.
Fixed the statemapper eating up "classes"
If you assigned a class instance to your state the typings from
getState/useStoreStateetc would report your type as being something similar to:With this fix your state will correctly be reported back as the actual class type (
Personin the examples case).Fixed action mapper so that state isn't display when viewing actions
The VSCode intellisense for actions were showing state. The types have been patched so that only actions will be displayed.
Fixed state mapper where actions were still being represented on state
There were cases if you had a nested action and only primitive state next to it that you would see the nested action. This is no longer the case.
Fixed computed properties state resolvers not inferring resolved types correctly
If you used a state resolver array within your computed properties, whilst using TypeScript, the inferred types based on the resolved state was incorrect. This is now fixed.
v3.3.1Compare Source
This is a no-op release that just fixes latest on
npmdue to an accidental publish.v3.3.0Compare Source
Minor Changes
Patches
reducercomment block in the Interop recipe.: #310e9b4a1b746ed5b6c5b8f6063ff4a90dec92Credits
Huge thanks to @joelmoss, @loveforweb, @gamtiq, @jaredmeakin, and @nickmeldrum for helping!
v3.2.6Compare Source
Patches
52c396b81e3c0aafe755cfe617fdbb51fc072e607051c633f07abd4c3bd3de53b5186bCredits
Huge thanks to @crissdev for helping!
v3.2.5Compare Source
v3.2.4Compare Source
v3.2.3Compare Source
Patches
501f237v3.2.2Compare Source
Patches
16c7d1338de86901fd0775e033e2v3.2.1Compare Source
Patches
bd9e978v3.2.0Compare Source
Minor Changes
Patches
2ce5f1a627fd17v3.1.2Compare Source
Patches
7f13514v3.1.1Compare Source
Patches
e199314fb63aacv3.1.0Compare Source
Minor Changes
e128e1ePatches
740d1a452a85615963568c92ff7ce0ddb22d3cc2b566da04165a2fd8c4efa4fea8aa8308ab8d9v3.0.3Compare Source
v3.0.2Compare Source
Patches
ee424b46992dc9a4202a7v3.0.1Compare Source
Patches
6becae1v3.0.0Compare Source
v3 is considered the realisation of the "final" Easy Peasy API - taking all the evolution and learning from v2 to produce a long term stable API that we will commit to supporting and will do our best to avoid breaking changes moving forward.
New Features
Hot reloading support
Hot reloading is supported via the
store.reconfigure(model)API. See #168New actionOn and thunkOn APIs
These are the new and only APIs by which to define action/thunk listeners with.
The v3 website has been updated with tutorials and API docs introducing these APIs.
We are really sorry about the churn around listener APIs! This API was driven by community feedback so feeling far better about it. 👍
Breaking Changes
Removed deprecated APIs
listen(use the new actionOn or thunkOn APIs instead)actionandthunkcan no longer be configured as listeners (use the new actionOn or thunkOn APIs instead)select(use computed instead)selector(use computed instead)useStore(renamed to useStoreState)useActions(renamed to useStoreActions)useDispatch(renamed to useStoreDispatch)triggerListenertriggerListenersuseStoreState(import from 'easy-peasy' or use createTypedHooks for TS)useStoreActions(import from 'easy-peasy' or use createTypedHooks for TS)useStoreDispatch(import from 'easy-peasy' or use createTypedHooks for TS)Thunks can be either asynchronous and synchronous
Using
async/awaitor returning aPromisefrom a thunk will maintain its previous async behaviour.However, if you do neither of the above your thunk will be executed synchronously. Therefore you can now get eager updates to your state if all you do is dispatch actions within your thunk. This can be handy for encapsulating logic based action dispatching.
For example
Returning immutable state from actions
If you prefer to return new immutable state from your actions, rather than mutating the state, you need to set the new
disableImmerflag.Failing to disable immer may result in strange errors if you are using computed properties.
computed
In order to optimise the Typescript experience we have made a fairly small change to the computed API. If you wish to use state resolvers, these now need to be defined as the first argument.
Before
After
Computed properties not using state resolvers remain unchanged.
useStoreState API update
useStoreState
(previouslyuseStore) no longer needs/accepts the dependencies 2nd argument. Your state will get mapped correctly if they use external values, like props, within themapState` function.Typescript
We officially support >=
typescript@3.5.1. Although we recommend using the latest version (typescript@3.5.3at the time of writing), in order to ensure you are up to date with the latest bug fixes.Create React App users can just install
typescript@3.5.3as a dev dependency and the CRA build system will use that version. You may get a warning printed to your console, however, we experienced no issues with this. 👍Hooks
You will have noted above that the
useStoreState,useStoreActions, anduseStoreDispatchare no longer attached to the store instance. You need to use the createTypedHooks helper instead.Computed
The
Computedtype no longer requires you to define the types for state resolvers. These will automatically be inferred.Before
After
Commits
f5fbe87ba955a50a06ee878dc4d455375dc7ce3188ff6cd76858c96b0bdbdad8b8bdcebff2d9c7545e638086cb270287db4b30b9f754d6a285e8f7b6f2826f56c871f42dc2e109ac40f4cb3ec3cd14db11ff97f76145efa75ce14ce8aa7bdd37943dde12c2c1c51bf7b3ad4eb8c4ffa2d926ce3e300c57461d42e3f821757a382e8d93a01cca321b239b80a388aed9af77cb49925c68c3a16e10332c80bb23993a49e4f25270dc6a80112da809c278dfc420968721b858204ff9f3152b0eada9649ee9e39261d239e519d0672e78606e67acd35153c95eb5efbee0ad6e4859b90efd3d02be472b17f821513526ba9f4f8cc0646512ada83d7292804fc9ee9d82706d225ae789a7c978806147021dfaf0cc9f221da6efd17e961a4fcc465d9878923e3d9aa182412c77fa297302Configuration
📅 Schedule: Branch creation - "before 3am on Monday" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.