- Fixed memory leak
- Added injectable actions. You can now use any Angular Injectable services in actions 🔥
- Simplified testing
- Updated to Angular 18+
- Added signal action
actions = signalActions(TodoActions);
- Reduced boilerplate when working with signal actions
- Updated to Angular 16+
- Added Signals support
- Migrated to latest (4.3.0) ImmutableJs
- Added
onChangePairwise
to form bind options to be able to get state pairwise (old one and current one).
- Added
snapshot
function to store. Now you can doconst value = store.select(['layout', 'test']).snapshot();
which will return state value.
- Fixed infinite loop which was caused by setting initial value to form after bind with
emitEvent: true
- Updated SSR restore functionality
- Improved merging for immer data strategy to create state object if not exists to prevent errors while merging
- Updated to Angular 13.3.10
- Updated all libraries like rxjs, immer etc.
- Added small fix to not crash when trying to load state from storage which is not available
- Fixed bug with observable notification timing when saving, loading, clearing persistent storage
- Fixed bug with dynamic state initialization when setting initial state via
@InjectStore([], {prop: 'val'})
. Wrong store was returned on second initialization (when returning to component).
- Angular version bump
- Added StoreModule as a generic parameter for Ivy compiler
- Fixed reset functionlaity
- Fixed immutability issues with immer
- Fixed in-InjectStore decorator initialization
- Added window object initialization for platforms that does not have it (nativescript).
- Removed
@angular/platform-browser
dependency. No in order to load state from server you need to passTransferState
andmakeStateKey
torestoreFromServerOptions
;
- fixed infinite loop with
emitEvent
when using form plugin. This loop was caused by updating forms state manually from code. Keep in mind that if you update state manually forms hooksshouldUpdateState
andonChange
will not be triggered.
- added
listenTo
method toDispatcher
. It returns Observable and can be used withtakeUntil
and other RxJs functions
- migrated to Angular 8
- added Ivy support
- added Angular TestBed support
- added optional type(T) notation to
select
operator in order to remove explicite type setting in subscription:...select<{somestate: string}>(...).subscribe(state => state.somestate...)
- added immer 5.0.0 as peer dependency
- fixed
clear
operator
- immutable data stratgey retruned to optional
withMutations
strategy in order fix the bug when working with lists. Only limited amount of operators can be applied when used withMutations. Read more about it on: (immutable documentation)(https://immutable-js.github.io/immutable-js). To usewithMutations
you need to add last argument instore.update
function like:this.store.update(...action, {}, { withMutations: true } as ImmutableUpdateActionAdditionalSettings)
. In order to get this fix applied please upgrade@ng-state/store
and@ng-state/immutablejs-data-strategy
- made library compatible with any compile targets like es2015...esnext
- Added optimistic updates API. Can be accessed via:
store.optimisticUpdates.
- Intorduced immer support
- In order to use ng-state now you have to import
@ng-state/store
instead ofng-state
and immer of immutable strategy module:ImmerDataStrategyModule
orImmutableJsDataStrategyModule
- Also for test bed you need to place
NgStateTestBed.setTestEnvironment(new ImmerDataStrategy());
to beforeEach and provide immer or immutable data strategy.
- Added type to state
- Improved information of history items
- Redux DevTools
maxAge
now is set fromstoreHistoryItems
property
- Simplified code and code test coverage
- Added integration with Redux DevTools - documentation
- Improved debugging experience
- Removed clear operator. Instead use immutable operator
store.update(state => state.clear())
. Previouse functionality of clear operator was moved toreset
to avoid confusion - Time travel was removed because of integration with Redux DevTools. You do not need to include
<state-history></state-history>
to your app.component.ts file.
- persist state plugin return observable on
save
,load
,removeItem
,clear
actions. onChange
andshouldUpdateState
hooks are added to form manager plugin
- fixed bug which di dnot allow to set default storage
- Added new Reset operator
- Added store.form.bind plugin for binding to reactive forms
- Added ability to store state to external storagies like localStorage or async storagies like IndexDB
- Fixed bug with inheritacne.
- Switched to ng build
Added transfer state support for Server Side Rendering
- Migrated to Angular 6 and RxJs 6.
- Added createStore method to NgStateTestBed
- Fixed bug with related to AOT. ngOnInit, ngOnDestory and ngOnChanges hooks were not hitted when compiled with AOT during to Angular limitations. This was not an issue with JIT. this issue relates to: microsoft/vscode#25853
- Simplified TestBed. Now
initial state
andstatePath
are optional and has defult values of{}
and[]
. More info in Readme.
- ngOnChanges is not called before actions not initialized (before ngOnInit). This behaviour can be disabled passing
true
as a second param toComponentState
decorator.
- Added IS_TEST provider.
- Improved constructor ovveride by ovveriding prototype but not instance constructor.
- Added
NgStateTestBed
for simplified actions and components unit testing.
- Upgraded to Angular 5.0.0
- Upgraded RxJs to ^5.5.0
- Upgraded Zone.js to ^0.8.18
- Upgraded immutable-cursor to ^2.0.0
- Upgraded core-js Angular ^2.5.0
- AOT fixes
- store.clear() added
- disableWarnings renamed to isProd
- when isProd all manipulations with state from
window
object are not allowed. - simplified initial state declaration from function to simple object:
export const initialState = {
todos: [],
interpolationTest: 'initial'
};
- added posbiity to return state from actions without store
get todos() { return this.state.get('todos'); }
. Because of this functionality all components that extendHasStateActions
should passChangeDetecotrRef
to its constructor. Otherways only store has to be used in actions. State update should be still done through store.update. - if component extends
HasStateActions
but does not have constructor and do not passChangeDetecotrRef
warning will be shown in console. To suppress it new variabledisableWarnings
was added toStoreModule
- debuging was simplyfied. Added
startDebugging
andstopDebugging
methods to window.state.startDebugging
takes optional array parameterstatePath
to watch over some state part. Also additional paramdebug = true / false
was added to InjectStore decorator. When set totrue
console will show state part of the component that uses those actions. currentState
getter was added to injectableStateHistory
to avoid usingwindow.state.CURRENT_STATE
in code
- added readonly
stateIndex
to HasStateActions. This is usefull when you want to edit list item on different route for instance and want to pass list index not via params but via route. - Added readonly
state
to actions. Now it is up to developer to use observable store or static state. But since it is readonlystate.set
and other update methods will not have any effect. - Fixed bug compilation error on first startup
- Initial state, that is passed to StoreModule, is not longer a function but simple object
- Introduced classes HasStateActions and HasStore to reduce boilerplate in components and actions. There is no more need to introduce actions, state and store in each component or store in actions.
export class TodoDescription extends HasStateActions<TodoStateActions> {
// this.actions is available
}
export class TodosStateActions extends HasStore<Immutable.List<any>> {
// this.store is available
}
state
has been removed due to perfrmance and consistency issues.
- Renamed 'state' to 'actions' in components to keep consistant with react library version
- Improved errors handling
- Added optional parameter to store.update - wrapToWithMutations because wrapping everything to immutable.withMutations causes unexected behaviour when working with Immutable.List. E.g. state.delete(1) returns empty list but not list without second element. Findout more in http://facebook.github.io/immutable-js/docs/#/List -> delete()
- Fixed variuos bugs
- Improved performance by converting getters to properties