Function: withImmutableState()
Call Signature
withImmutableState<
State
>(state
,options
?):SignalStoreFeature
<SignalStoreFeatureResult
,EmptyFeatureResult
&object
>
Defined in: libs/ngrx-toolkit/src/lib/immutable-state/with-immutable-state.ts:67
Prevents mutation of the state.
This is done by applying Object.freeze
to each root
property of the state. Any mutable change within
or outside the SignalStore
will throw an error.
Root properties of the state having a primitive data type are not supported.
- For example:
const state = {
// ⛔️ are not frozen -> mutable changes possible
id: 1,
// ✅ are frozen -> mutable changes throw
address: {
street: 'Main St',
city: 'Springfield',
}
}
Type Parameters
• State extends object
Parameters
state
State
the state object
options?
enable protection in production (default: false)
enableInProduction
boolean
Returns
SignalStoreFeature
<SignalStoreFeatureResult
, EmptyFeatureResult
& object
>
Call Signature
withImmutableState<
State
>(stateFactory
,options
?):SignalStoreFeature
<SignalStoreFeatureResult
,EmptyFeatureResult
&object
>
Defined in: libs/ngrx-toolkit/src/lib/immutable-state/with-immutable-state.ts:102
Prevents mutation of the state.
This is done by applying Object.freeze
to each root
property of the state. Any mutable change within
or outside the SignalStore
will throw an error.
Root properties of the state having a primitive data type are not supported.
- For example:
const state = {
// ⛔️ are not frozen -> mutable changes possible
id: 1,
// ✅ are frozen -> mutable changes throw
address: {
street: 'Main St',
city: 'Springfield',
}
}
Type Parameters
• State extends object
Parameters
stateFactory
() => State
a function returning the state object
options?
enable protection in production (default: false)
enableInProduction
boolean
Returns
SignalStoreFeature
<SignalStoreFeatureResult
, EmptyFeatureResult
& object
>