Skip to content
William Horn edited this page Jul 23, 2019 · 6 revisions

Docs

Getting data from the store

State

export interface FiltersState {
  dateRange: DateRangeState;
  ...more properties
}

Example state

State Selector

The selector is used to get a specific slice of the state object.

export const getStartDate = createSelector(
  getFiltersState,
  (state: FiltersState) => state.dateRange.start // Pull out the start date
);

Example selector

Using the selector

This is the arrow from the state bubble to the component in the diagram. store$.select can be used anywhere the Store service can be injected.

const startDate$: Observable<Date> = this.store$.select(getStartDate);

example function