Bird
0
0

Given this Effect code snippet:

medium📝 component behavior Q13 of 15
Angular - Signals
Given this Effect code snippet:
loadData$ = createEffect(() => this.actions$.pipe(
  ofType('LOAD_DATA'),
  tap(() => console.log('Data loading started'))
), { dispatch: false });

What will happen when the 'LOAD_DATA' action is dispatched?
AThe message 'Data loading started' is logged, and no new action is dispatched
BThe message is logged and a new action is dispatched automatically
CNothing happens because dispatch is false
DAn error occurs because tap cannot be used here
Step-by-Step Solution
Solution:
  1. Step 1: Understand the effect's dispatch option

    Setting dispatch: false means this Effect does not send out new actions after running.
  2. Step 2: Analyze the tap operator

    The tap operator runs side code like logging but does not change or dispatch actions.
  3. Final Answer:

    The message 'Data loading started' is logged, and no new action is dispatched -> Option A
  4. Quick Check:

    dispatch false means no new action, tap logs side effect [OK]
Quick Trick: dispatch: false means no new action dispatched [OK]
Common Mistakes:
  • Assuming tap dispatches actions
  • Thinking dispatch: false disables effect
  • Confusing tap with map or switchMap

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes