Immutability out of the box

Runtime checks for immutability and serializability were introduced in version 8, to aid developers in maintaining best practices when managing state. Two of these runtime checks, strictStateImmutability , and strictActionImmutability are now enabled by default in development, so developers can be assured that their state following immutable practices out of the box.

There is also a new runtime check for validating that actions are dispatched from within the Angular zone. If you’re dealing with less modern web APIs, such as jQuery, that operate outside the Angular zone, this check helps you catch bugs that would occur because of bypassed Angular change detection.



imports: [

StoreModule.forRoot(reducers, {

runtimeChecks: {

strictActionWithinNgZone: true,

},

}),

],

})

export class AppModule {} @NgModule ({imports: [StoreModule.forRoot(reducers, {}),],})export class AppModule {}

Thanks to Stephen Cooper for contributing to this feature!

Creators syntax is now the default!

The new creators syntax, announced in version 8 is now the default for all schematics in version 9. The new syntax allows you to get up and running quickly with less code, and more type-safety. If you are still using the previous syntax, support for it is also still available.

Read our docs, and check out our example application if you haven’t tried out the new syntax already.

Customizable re-subscriptions for Effects

Also introduced in version 8, was the ability to resubscribe to an observable inside an Effect when an error occurs. In version 9, we limit this behavior to 10 retries, and offer the ability to customize the re-subscription behavior according to your needs.

@NgModule({

imports: [EffectsModule.forRoot([MovieEffects])],

providers: [

{

provide: EFFECTS_ERROR_HANDLER,

useValue: customEffectResubscriptionHandler,

},



],

})



// adjust the number of retries

const CUSTOM_NUMBER_OF_RETRIES = 100;



export function customEffectResubscriptionHandler<T extends Action>(

observable$: Observable<T>,

errorHandler: CustomErrorHandler

): Observable<T> {

return defaultEffectsErrorHandler(

observable$,

errorHandler,

CUSTOM_NUMBER_OF_RETRIES

);

}

Thanks to Zak Henry for contributing to this feature!

Breaking Changes

This release contains breaking changes. For most of these breaking changes we’ve provided a migration that automatically runs when you upgrade your application with the Angular CLI command mentioned above.

Take a look at the version 9 migration guide for complete information regarding migrating to the latest release. The complete CHANGELOG can be found on our GitHub page.

Upgrading to NgRx 9

To start using NgRx 9, make sure to have the following minimum versions installed:

Angular version 9.x

Angular CLI version 9.0.1

TypeScript version 3.7.x

RxJS version 6.5.x

NgRx supports using the Angular CLI ng update command to update your NgRx packages. To update your packages to the latest version, run the command: