State Management & Change Detection Flashcards
6 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 State Management & Change Detection flashcards as text
Which Angular strategy checks only the current component and its ancestors when an input reference changes?
Answer: OnPush
OnPush change detection only runs for a component when its input references change, an event originates from it, or an async pipe resolves.
What method on ChangeDetectorRef temporarily stops change detection for a component subtree?
Answer: detach()
detach() removes the component from the change detection tree until reattach() is called.
Which NgRx building block is a pure function that takes the current state and an action, and returns a new state?
Answer: Reducer
A reducer is a pure function (state, action) => newState that never mutates the existing state object.
In NgRx, which construct handles side effects such as HTTP calls and dispatches new actions on completion?
Answer: Effect
NgRx Effects listen for dispatched actions, perform side effects, and optionally dispatch new actions back to the store.
Which NgRx function creates a memoized, reusable piece of state-derived data?
Answer: createSelector()
createSelector() returns a memoized selector that recomputes only when its input selectors produce new values.
What does calling markForCheck() on a component using OnPush change detection do?
Answer: Marks the component and its ancestors to be checked on the next cycle
markForCheck() flags the component and its ancestors so Angular includes them in the next change detection run.