0

It it normal for a ngrx selector to have an emitted value despite no action is dispatched at all?

This console.log runs here even if no actions are dispatched in my app

this.bookmarks$ = this.store.pipe(
  select(fromBookmarks.selectBookmarks),
  tap(_ => console.log('fetch bookmarks'))
);

Would it be okay to skip(1) the first emission or it's kinda hacky.

Kid
  • 36
  • 5
The.Wolfgang.Grimmer
  • 1,172
  • 2
  • 9
  • 32

1 Answers1

1

Yes, the selectors and actions independent: selectors query the state, and reducers listen to actions in order to update the state. So:

  • There is always a state, a initial state when app starts ==> selector will always return a value
  • Actions will not always make changes to state, they can be ignored by reducers.
HTN
  • 3,388
  • 1
  • 8
  • 18