N
N
Nikolay Semenov2018-08-16 09:42:22
JavaScript
Nikolay Semenov, 2018-08-16 09:42:22

What expression is typescript expecting?

Guys hello everyone. There is such a code

@Effect({dispatch: false})
    authLogout = this.actions$
      .ofType(AuthActions.LOGOUT)
      .pipe (do(() => {
        this.router.navigate(['/']);
      }))

and typyscript writes that "an argument expression was expected" And which one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Mazhekin, 2018-08-16
@nickola105

The effect should return some kind of action in the pipe. To make the transition in the reducer to the next action. https://github.com/ang5-examples/ngrx-store-effect...
And it seems that routing in the effect is not the best place. There, for example, data is being pumped from external sources, such as api, localstorage, etc. And then this data is merged to be passed to the next action.
https://github.com/ngrx/effects/blob/master/docs/i...
Even if it is not planned to proceed to the next action (dispatch: false). You still need to return (in switchMap) something observable or at least null.
www.wisdomofjim.com/blog/how-to-create-an-ngrx-eff...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question