- Akita now complied with
target: ES2020. - Remove coupling to Angular by removing the
ngOnDestroymethod from the store. If you're using a store inside a component's provider, you need to call it manually:
@Injectable()
class TodosStore extends Store {
ngOnDestroy() {
this.destroy();
}
}- All Angular packages peer dependency is Angular v13.
- Remove the
effectspackage in favor of ngneat/effects
- Upgrade to TS v4 and support tslib v2.0
- New effects package
- Updated
QueryEntitytyping ofselect/getmethods to respectundefinedentity values. - Remove deprecated array utils functions.
- Remove deprecated
excludeoption from persist state. Useincludewith a callback option. - The
upsertoperator ofEntityStorenow accepts an explicit entity initialization callback that'll be used as the initial value of the entity if it doesn't exist. ( this isn't a breaking change )
store.upsert(
[2, 3],
(entity) => ({ isOpen: !(entity?.isOpen ?? true) }),
(id, newState) => ({ id, ...newState, enabled: true })
);- The
runStoreActionis rewritten as well to support type safe entity operations:
// Before
runStoreAction('books', StoreActions.UpsertEntities, {
payload: {
data: { title: 'New Title' },
entityIds: [2, 3],
},
});// After
runEntityStoreAction(BooksStore, EntityStoreAction.UpsertEntities, (upsert) => upsert([2, 3], { title: 'New Title' }, (id, newState) => ({ id, ...newState, price: 0 })));It also takes the store name as string.
- A new select option for the
persistStateplugin.
Most of the breaking changes in this version are related to types changes.
- EntityStore and QueryEntity now don't require the second generic entity type:
// Before
export interface ProductsState extends EntityState<Product> {}
@StoreConfig({ name: 'products' })
export class ProductsStore extends EntityStore<ProductsState, Product> {
constructor() { super();
}
export class ProductsQuery extends QueryEntity<ProductsState, Product> {
constructor(protected store: ProductsStore) {
super(store);
}
}
// After
export interface ProductsState extends EntityState<Product> {}
@StoreConfig({ name: 'products' })
export class ProductsStore extends EntityStore<ProductsState> {
constructor() { super();
}
export class ProductsQuery extends QueryEntity<ProductsState> {
constructor(protected store: ProductsStore) {
super(store);
}
}For now, we keep a deprecated generic, so it will not break any existing code, but please, don't use it anymore.
- Removed the unused error state type -
EntityState<Product, StateErrorType>. - Custom ID type location is changed:
// Before:
export interface ProductsState extends EntityState<Product> {}
@StoreConfig({ name: 'products' })
export class ProductsStore extends EntityStore<ProductsState, Product, string> {
constructor() { super();
}
// After
export interface ProductsState extends EntityState<Product, string> {}
@StoreConfig({ name: 'products' })
export class ProductsStore extends EntityStore<ProductsState> {
constructor() { super();
}- Removed deprecated
selectUpdatedEntityIdsmethod in favor ofselectEntityAction. - Removed deprecated
waitForTransactionmethod in favor ofauditTime. - The default entity id type changed from
IDwhich wasnumber | stringtoany. We now recommend to strict your type in the secondEntityStategeneric parameter.
Entity plugins now require one generic, which is the store's type instead of the entity type.
new EntityDirtyCheckPlugin<WidgetsState>new EntityStateHistoryPlugin<WidgetsState>new PaginatorPlugin<WidgetsState>
- Firebase integration.
- In dev mode, you can now use
window.$$storesandwindow.$$queriesto obtain a reference to the stores or the queries. - persistState plugin performance optimization option.
- persistState plugin custom hooks support.
- Add a
replacemethod to EntityStore. - PaginatorPlugin add a
refreshCurrentPagemethod. - HistoryPlugin add a custom clear function.
- selectEntity now support predicate function -
query.selectEntity(e => e.title === 'title'). - Add Entity Actions API.
StoreConfigcan take a custom deep freeze function.
EntityStore.set()- removeoptionsparam, i.eentityClass..- Remove
EntityStore.createOrReplace()in favor ofEntityStore.upsert(). - Remove
EntityStore.updateRoot()in favor ofEntityStore.update(). - Remove
EntityStore.updateAll()in favor ofEntityStore.update(null, newState), Store.setStateis internal and changed to_setState()- use only theupdate()method.- Remove
mapWorker. - Remove array helpers.
- Remove
decrementandincrementfunctions. - Remove
Query.selectOnce- useselect().pipe(take(1)). - Remove deprecated
Query.getSnapshot(). - Remove
noop- use theof()observable. - Remove
isPristineandisDirtyin favor of newcachingfunctionality. - The
actiondecorator takes the action name instead of an object. - Remove
EntityStore.isEmptyin favor ofEntityStore.hasEntity().
- Update typescript to v3.2.
- Remove the
getInitialActiveState()function. - Entity dirty check plugin: remove deprecated
isSomeDirtyandsomeDirty.
- Deprecate
getSnapshot()in favor ofgetValue(). - Remove redundant
optionsparam fromselectMulti, - When using the
activefunctionality always add the initialactivestate. For single:
export interface State extends EntityState<Widget>, ActiveState {}
const initialState = {
active: null,
};
@StoreConfig({ name: 'widgets' })
export class WidgetsStore extends EntityStore<WidgetsState, Widget> {
constructor() {
super(initialState);
}
}And for multi:
export interface State extends EntityState<Widget>, MultiActiveState {}
const initialState = {
active: [],
};
@StoreConfig({ name: 'widgets' })
export class WidgetsStore extends EntityStore<WidgetsState, Widget> {
constructor() {
super(initialState);
}
}- Add support for multiple active entities 馃帀
filterNiloperator strongly typedselectFirstandselectLastselectors