useSelect

A facade can be enhanced with usePick, which can proceed NgRx's selectors and transforms them into consumable Observable-streams.

This allows the facade to read data from different State-Slices that are not part of the facade itself.

Selector

To set up useSelect a property needs to be added to the facade that is assigned with usePick(). In the Component, each and every selector of the project can be passed to pick. The result type of the selector is inferred automatically and provides the correct type information.

import { useSelect, StoreFacade } from '@ngrx-ducks/core';

@StoreChunk()
export class Chunk {
  select = useSelect();
}

Selector with props

Pick also accepts selectors having properties (selectors with props). The pick-Function than expects a second parameter representing the properties (see component.ts).

import { createDuck, useSelect } from '@ngrx-ducks/core';

@StoreChunk()
export class Chunk {
  select = useSelect();
}

Last updated