All quizzesEasy
Actions & Reducers — Series 2
Preview — 3 of 10 questions
What does this give you beyond a plain reducer?
javascript
export const heroesFeature = createFeature({
name: 'heroes',
reducer: createReducer(initialState, on(loaded, (s, { heroes }) => ({ ...s, heroes }))),
});ANothing; it is a naming convention
BIt registers the feature globally at import time
CIt bundles the feature name, the reducer and generated selectors — selectHeroesState plus one per state property — so the common selectors do not have to be written by hand
DIt replaces effects
What does this return?
javascript
heroes = this.store.selectSignal(selectAllHeroes);AAn observable that must go through the async pipe
BA promise of the current value
CA snapshot array, read once
DA signal — read as heroes() in the template, with no subscription to manage and no async pipe
Is this valid?
javascript
this.store.subscribe((state) => console.log(state));ANo — Store has no subscribe
BYes — Store extends Observable<State>, so subscribing yields the whole state on every change. It is valid and almost always the wrong granularity: any change anywhere emits
CYes, and it emits only once
DOnly inside an effect
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.