- BREAKING: skip support angular schematics
- Feat: improved type checking
- Feat: support Angular 12
- Feat: refactor persistence decorator
- Fix: support Angular 11.2+
- Feat: add
entitiesArray
,entitiesArray$
toAbstractNgxsDataEntityCollectionsRepository
- Fix: invalid expose arguments when inheritance
- Feature: support only Ivy
- Feature: feat: support Angular 10, TypeScript 4
- Feature: support
@ngxs/store@3.7.0
- Fix: Proxy is a ES2015 class that is not compatible with IE11 with ES5 target
- Moved
Immutable, Mutable, Any
interfaces to@angular-ru/common/typings
:
import { Immutable, Mutable, Any } from '@angular-ru/common/typings';
- Moved
createEntityCollections
to@angular-ru/common/entity
:
import { createEntityCollections } from '@angular-ru/common/entity';
@StateRepository()
@State({
name: 'students',
defaults: createEntityCollections()
})
@Injectable()
class StudentEntitiesState extends NgxsDataEntityCollectionsRepository<StudentEntity, string> {
public selectId(entity: StudentEntity): string {
return `${entity.groupId}_${entity.batchId}`;
}
}
- Removed
NgxsDataMutablePipe, NgxsDataUtilsModule
- Fix: entry point '@ngxs/store/src/*' contains deep imports into in lib
- Feature: support Angular Schematics
ng add @ngxs-labs/data
- Feature: make
NgxsDataEntityCollectionsRepository<V, K, C>
extensible - Feature: support sort entities
- Feature: add
ngxsTestingPlatform
as tools for better testing - Feature: add
ngxsDataDoCheck
,ngxsDataAfterReset
lifecycle hooks - Feature: expose
@Computed()
for automatically computed values from state - Feature: expose
NgxsDataRepository<T>
for working with classic mutable data - Feature: expose
NgxsImmutableDataRepository<T>
for working with immutable data - Feature: expose
NgxsDataEntityCollectionsRepository<V, K>
for working with entity collections - Feature: expose
@Payload()
decorator for register payload in action - Feature: expose
@Named()
decorator for register name in action - Feature: expose
@Debounce()
decorator for throttling dispatch actions - Feature: add extension API for NGXS Data plugin
- Feature: expose storage extension as plugin
- Feature: support observers for listening expiration time to live
- Feature: add fire init option to
@Persistence()
- Feature: add rehydrate option to
@Persistence()
- Feature: add
ngxsDataStorageMigrate
lifecycle hook - Feature: add
ngxsDataAfterStorageEvent
lifecycle hook - Feature: add
insideZone
option to@DataAction()
- Fix: Function expressions are not supported in decorators
- Fix: hide
Angular is running in the development mode
message in testing mode - Fix: support migration strategy
- Fix: support decode/encode data in storage
- Fix: improved
@Persistence()
decorator for stability - Fix: use deep equals when state update in storage from another browser tab
- Fix: now
@Computed()
fields are recalculation when store has changed - Fix: correct recalculation of state during inheritance computed fields
- Fix: correct inheritance of state classes
- Fix: compatibility with
@ngxs/store@3.6.2
- Fix: correct value freeze from
getState()
- Fix: memory leak in storage extension
- Fix: can now global override prefix key without
@Persistence
decorator
- Renamed decorator
@action()
to@DataAction()
- Renamed decorator
@computed()
to@Computed()
- Renamed decorator
@debounce()
to@Debounce()
- Renamed decorator
@named()
to@Named()
- Renamed decorator
@payload()
to@Payload()
- Removed
@query
decorator - Now require minimal
@ngxs/store v3.6.2
- Now require minimal
TypeScript v3.7.2
- Other breaking changes:
If you are using Angular 8, you can write in the tsconfig.json
:
{
"angularCompilerOptions": {
"disableTypeScriptVersionCheck": true
},
"compilerOptions": {}
}
- Now you need to explicitly set the payload:
// BEFORE
@StateRepository()
@State<string[]>({
name: 'todo',
defaults: []
})
@Injectable()
export class TodoState extends NgxsImmutableDataRepository<string[]> {
@action()
public addTodo(todo: string): void {
if (todo) {
this.ctx.setState((state) => state.concat(todo));
}
}
}
// AFTER
@StateRepository()
@State<string[]>({
name: 'todo',
defaults: []
})
@Injectable()
export class TodoState extends NgxsImmutableDataRepository<string[]> {
@DataAction()
public addTodo(@Payload('todo') todo: string): void {
if (todo) {
this.ctx.setState((state) => state.concat(todo));
}
}
}
- The
type, async, debounce
action options are not longer support, also now it is necessary to use thepayload
decorator for logging send value:
// BEFORE
@StateRepository()
@State({
name: 'app',
default: ''
})
@Injectable()
class AppState extends NgxsImmutableDataRepository<string> {
@action({ async: true, debounce: 300 })
public concat(text: string): void {
this.setState((state) => `${state}${text}`);
}
}
// AFTER
@StateRepository()
@State({
name: 'app',
default: ''
})
@Injectable()
class AppState extends NgxsImmutableDataRepository<string> {
@Debounce()
@DataAction()
public concat(@Payload('text') text: string): void {
this.setState((state) => `${state}${text}`);
}
}
- Moved common interfaces to
@ngxs-labs/data/typings
:
import { Immutable, Mutable } from '@ngxs-labs/data/typings';
- For a cast state to mutable type it is necessary to use package
@ngxs-labs/data/utils
:
import { NgxsDataUtilsModule } from '@ngxs-labs/data/utils';
@NgModule({
imports: [
// ..
NgxsDataUtilsModule
]
})
export class AppModule {}
@Component({
//..
})
class TodoComponent {
@Input() public data: string[];
}
@Component({
selector: 'app',
template: '<todo [data]="todos.state$ | async | mutable"></todo>'
})
class AppComponent {
constructor(public todos: TodosState) {}
}
- For start work with storage plugin you need provide
storage extension
:
import { NgxsDataPluginModule } from '@ngxs-labs/data';
import { NGXS_DATA_STORAGE_CONTAINER, NGXS_DATA_STORAGE_EXTENSION } from '@ngxs-labs/data/storage';
@NgModule({
// ..
imports: [
NgxsModule.forRoot([AppState], { developmentMode: !environment.production }),
NgxsDataPluginModule.forRoot([NGXS_DATA_STORAGE_EXTENSION, NGXS_DATA_STORAGE_CONTAINER])
]
})
export class AppModule {}
- All decorators are now exported from a subpackage:
import { DataAction, Persistence, StateRepository } from '@ngxs-labs/data/decorators';
- All repositories are now exported from a subpackage:
import { NgxsImmutableDataRepository } from '@ngxs-labs/data/repositories';
- Fix: preserve mutate
getState()
when run angular dev mode
- Feature: add freeze state when run angular dev mode for selection stream
- Feature: expose
mutable
pipe for casting immutable stream to mutable stream
- Fix: corrected reset with children states
- Fix: corrected automatic type inference in ctx.setState
- Fix: disable automatic subscription of observables inside the action method
- Fix: remove duplicate field in DataStorageEngine
- Fix: remove an infinite loop when triggered onstorage event
- Feature: enable strict typings
- Fix: downgrade typescript for compatibility angular build
- Feature: storage plugin
out of the box
- Fix: dispatch storage when first initial states
- Feature: Support TypeScript 3.7
- Feature: Support NGXS 3.6
- Compatible only with NGXS 3.6+
- Now
patchState, setState
returnvoid
- No longer support options in
NgxsDataPluginModule.forRoot()
- No longer support
@query
decorator