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.0
Release Notes
ctrlplusb/easy-peasy
v5.1.0
Compare Source
Minor Changes
Patches
connect
to Hooks ⚡: #652Credits
Huge thanks to @jmyrland, @avramch, @no-stack-dub-sack, @yethranayeh, and @troglodytto for helping!
v5.0.5
Compare Source
Patches
2fab9a2
c63555c
Credits
Huge thanks to @jmyrland for helping!
v5.0.4
Compare Source
Patches
ea98660
444396f
8640563
8fce26b
f24ab25
68fdfff
Credits
Huge thanks to @fbieler, @mfbx9da4, @yakovlevyuri, @w3bdesign, and @GavinRay97 for helping!
v5.0.3
Compare Source
## Patches
v5.0.2
Compare Source
Patches
772f1b5
v5.0.1
Compare Source
Patches
v5.0.0
Compare 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
memo
helper. 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.2
Compare Source
Patches
a72aa7e
v4.0.1
Compare Source
Patches
b39dd4e
Closes #565
v4.0.0
Compare 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
createComponentStore
with auseLocalStore
hookThe API for
createComponentStore
was 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@7
We 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
enableES5
feature from Immer.Moved internal
redux-thunk
binding 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
fail
helper 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
fail
helper 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_effectOn
Allows 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
stateResolvers
and thehandler
. ThestateResolvers
are an array of functions which should resolve the target state that should be tracked. When the tracked state changes thehandler
function is executed.The
handler
can be asynchronous or synchronous. It receives the store actions, achange
object containing theprev
values for the targeted state and thecurrent
values as well as theaction
that caused the change in state. It additionally receives ahelper
argument allowing you to access the store state etc.The
handler
additionally 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
Provider
for 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
State
andAction
types 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
Generic
type, and then assigned the associated value within the model instance using thegeneric
helper.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
number
in 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
/useStoreState
etc would report your type as being something similar to:With this fix your state will correctly be reported back as the actual class type (
Person
in 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.1
Compare Source
This is a no-op release that just fixes latest on
npm
due to an accidental publish.v3.3.0
Compare Source
Minor Changes
Patches
reducer
comment block in the Interop recipe.: #310e9b4a1b
746ed5b
6c5b8f6
063ff4a
90dec92
Credits
Huge thanks to @joelmoss, @loveforweb, @gamtiq, @jaredmeakin, and @nickmeldrum for helping!
v3.2.6
Compare Source
Patches
52c396b
81e3c0a
afe755c
fe617fd
bb51fc0
72e6070
51c633f
07abd4c
3bd3de5
3b5186b
Credits
Huge thanks to @crissdev for helping!
v3.2.5
Compare Source
v3.2.4
Compare Source
v3.2.3
Compare Source
Patches
501f237
v3.2.2
Compare Source
Patches
16c7d13
38de869
01fd077
5e033e2
v3.2.1
Compare Source
Patches
bd9e978
v3.2.0
Compare Source
Minor Changes
Patches
2ce5f1a
627fd17
v3.1.2
Compare Source
Patches
7f13514
v3.1.1
Compare Source
Patches
e199314
fb63aac
v3.1.0
Compare Source
Minor Changes
e128e1e
Patches
740d1a4
52a8561
5963568
c92ff7c
e0ddb22
d3cc2b5
66da041
65a2fd8
c4efa4f
ea8aa83
08ab8d9
v3.0.3
Compare Source
v3.0.2
Compare Source
Patches
ee424b4
6992dc9
a4202a7
v3.0.1
Compare Source
Patches
6becae1
v3.0.0
Compare 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)action
andthunk
can 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)triggerListener
triggerListeners
useStoreState
(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/await
or returning aPromise
from 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
disableImmer
flag.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
(previously
useStore) no longer needs/accepts the dependencies 2nd argument. Your state will get mapped correctly if they use external values, like props, within the
mapState` function.Typescript
We officially support >=
[email protected]
. Although we recommend using the latest version ([email protected]
at 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
[email protected]
as 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
, anduseStoreDispatch
are no longer attached to the store instance. You need to use the createTypedHooks helper instead.Computed
The
Computed
type no longer requires you to define the types for state resolvers. These will automatically be inferred.Before
After
Commits
f5fbe87
ba955a5
0a06ee8
78dc4d4
55375dc
7ce3188
ff6cd76
858c96b
0bdbdad
8b8bdce
bff2d9c
7545e63
8086cb2
70287db
4b30b9f
754d6a2
85e8f7b
6f2826f
56c871f
42dc2e1
09ac40f
4cb3ec3
cd14db1
1ff97f7
6145efa
75ce14c
e8aa7bd
d37943d
de12c2c
1c51bf7
b3ad4eb
8c4ffa2
d926ce3
e300c57
461d42e
3f82175
7a382e8
d93a01c
ca321b2
39b80a3
88aed9a
f77cb49
925c68c
3a16e10
332c80b
b23993a
49e4f25
270dc6a
80112da
809c278
dfc4209
68721b8
58204ff
9f3152b
0eada96
49ee9e3
9261d23
9e519d0
672e786
06e67ac
d35153c
95eb5ef
bee0ad6
e4859b9
0efd3d0
2be472b
17f8215
13526ba
9f4f8cc
0646512
ada83d7
292804f
c9ee9d8
2706d22
5ae789a
7c97880
6147021
dfaf0cc
9f221da
6efd17e
961a4fc
c465d98
78923e3
d9aa182
412c77f
a297302
Configuration
📅 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.