v2.6.0
Deprecation Release
My sincere apologies around the churn of APIs concerning derived data. The original select API had performance issues which were attempted to be addressed by the selector API. Unfortunately the selector helper may have been too eagerly released. It proved to create quite a bit of friction in terms of it's DX. I open an RFC to try and address these concerns and eventually the computed API was born. The computed API provides the same DX as the select API whilst addressing the performance issues. It also provides additional features in that you can isolate state and even derive against the entire store state. I humbly apologise if you had already migrated to the selector API, but kindly ask that you now migrate to the computed API.
I am extremely happy with the Easy Peasy API as it stands. I find that it addresses most of my concerns around global state, whilst still having a very intuitive/palatable API. From here on out I plan to cut v3 of the library which will remove all the deprecated APIs, which will drop the bundle size and open up some great performance optimisations.
Migration
Migration from select
to computed
The migration from select
to computed
is very straight forward. You can simply do a find and replace on select
and replace it with computed
.
Before
import { select } from 'easy-peasy';
const sessionModel = {
user: null,
isLoggedIn: select(state => state.user != null)
}
After
import { computed } from 'easy-peasy';
const sessionModel = {
user: null,
isLoggedIn: computed(state => state.user != null)
}
If you are using Typescript you can do a search and replace on Select
, replacing it with Computed
.
Before
import { Select } from 'easy-peasy';
interface SessionModel {
user: User | null;
isLoggedIn: Select<SessionModel, boolean>;
}
After
import { Computed } from 'easy-peasy';
interface SessionModel {
user: User | null;
isLoggedIn: Computed<SessionModel, boolean>;
}
Migration from selector
to computed
Coming soon...