Options
You can provide a config when you create your root NgxsModule
, as forRoot
accepts 2 arguments. The second argument is a ModuleOptions
object that can have such properties as developmentMode
, compatibility
and executionStrategy
.
Turning on
developmentMode
option will add additional debugging features, like freezing your state and actions to guarantee immutability. Default value isfalse
.compatibility
is an object that can havestrictContentSecurityPolicy
property, if you setstrictContentSecurityPolicy
totrue
, then the support for the strict Content Security Policy will be enabled. This will cirumvent some optimisations that violate a strict CSP through the use ofnew Function(...)
. Default value isfalse
.executionStrategy
is an advanced option. It is used to have specific control of the way that ngxs executes code that is considered to be inside the ngxs context (ie. within@Action
handlers) and the context under which the NGXS behaviours are observed (outside the ngxs context). These observable behaviours are:@Select(...)
,store.select(...)
,actions.subscribe(...)
orstore.dispatch(...).subscribe(...)
Developers who prefer to manually control the change detection mechanism in their application may choose to use the
NoopNgxsExecutionStrategy
(or implement their own) which does not interfere with zones and therefore relies on the external context to handle change detection (for example:OnPush
or ivy's rendering engine). The default value ofnull
will result in the default strategy being used. The default strategy runs NGXS operations outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone. The default value isnull
.
Last updated