Skip to main content

Function: withMapper()

withMapper<State>(map): DevtoolsFeature

Defined in: libs/ngrx-toolkit/src/lib/devtools/features/with-mapper.ts:30

Allows you to define a function to map the state.

It is needed for huge states, that slows down the Devtools and where you don't need to see the whole state or other reasons.

Example:

const initialState = {
id: 1,
email: 'john.list@host.com',
name: 'John List',
enteredPassword: ''
}

const Store = signalStore(
withState(initialState),
withDevtools(
'user',
withMapper(state => ({...state, enteredPassword: '***' }))
)
)

Type Parameters

State extends object

Parameters

map

(state) => Record<string, unknown>

function which maps the state

Returns

DevtoolsFeature