Conversation
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
=========================================
- Coverage 98.13% 96.7% -1.43%
=========================================
Files 12 12
Lines 535 364 -171
Branches 87 52 -35
=========================================
- Hits 525 352 -173
- Misses 8 10 +2
Partials 2 2
Continue to review full report at Codecov.
|
|
wow, that diff, so sexy |
|
Soooooo satisfying. |
Loving the convention and consistency! |
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
========================================
+ Coverage 98.13% 100% +1.86%
========================================
Files 12 12
Lines 535 353 -182
Branches 87 54 -33
========================================
- Hits 525 353 -172
+ Misses 8 0 -8
+ Partials 2 0 -2
Continue to review full report at Codecov.
|
|
Hi @ctrlplusb ! This is looking real good 👏 Because we have a pretty well testet system with easy-peasy integrated, I figured I would install the new version to check it out! Quick feedback: I would recommend moving the section about Loving the new listener API! For listeners against multiple actions - I assume returning an array from the "target resolver" is the way to go. If that is the case - a quick note in the docs would be great:
I'll continue my journey of upgrading & testing the new version. If I stumble upon something strange - I'll be sure to let you know! High-fives & well done to all the involved! 👏 🎉 🎊
|
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
==========================================
+ Coverage 98.13% 99.72% +1.58%
==========================================
Files 12 12
Lines 535 358 -177
Branches 87 55 -32
==========================================
- Hits 525 357 -168
+ Misses 8 1 -7
+ Partials 2 0 -2
Continue to review full report at Codecov.
|
…le across hook instances
* Progress on fixing listener TS * Refactors the type definitions for actionOn and thunkOn
Note
If you are upgrading from
easy-peasy@3.0.0-rc.0toeasy-peasy@3.0.0-rc.6please review the API and TypeScript docs relating toactionOn,thunkOn, andcomputed. In order to optimise the TypeScript DX I have made some breaking changes. Apologies for the break at RC phase, however, I hope you will agree it is worth it. As things stand I am very happy with where we are at. I will leteasy-peasy@3.0.0-rc.6sit for a short while and then will look to cuteasy-peasy@3.0.0. Any early adopters and feedback will be super appreciated. 👍Updated website
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.
Todo
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 would get eager updates to your state. This can be handy for encapsulating log based action dispatching within a think.
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 now requires >=
typescript@3.5.1if you use the Typescript definitions. 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. 👍Computed
The
Computedtype no longer requires you to define the types for state resolvers. These will automatically be inferred.Before
After