Bird
0
0

Why does this effect fail to dispatch any action?

medium📝 Debug Q7 of 15
Angular - State Management
Why does this effect fail to dispatch any action?
delete$ = createEffect(() => this.actions$.pipe(
  ofType('DELETE'),
  tap(action => this.api.delete(action.payload))
))
ABecause ofType is used incorrectly
BBecause tap does not return a new action to dispatch
CBecause createEffect requires a second argument
DBecause api.delete is not called
Step-by-Step Solution
Solution:
  1. Step 1: Understand tap operator

    tap performs side effects but does not transform or emit new values.
  2. Step 2: Effect must return an action

    Effects dispatch actions returned by the observable; tap alone does not emit actions, so no dispatch occurs.
  3. Final Answer:

    Because tap does not return a new action to dispatch -> Option B
  4. Quick Check:

    tap is for side effects, not dispatching actions [OK]
Quick Trick: Use map or switchMap to return actions, not tap alone [OK]
Common Mistakes:
  • Expecting tap to dispatch actions
  • Misunderstanding createEffect requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes