使用NgRX效果进行连锁服务调用

时间:2018-06-12 14:31:40

标签: angular rxjs ngrx

我有一个效果,使用NgRX 6

此效果会侦听REDIRECT_TO_LOGIN操作,然后应调用我的发现服务来检索2条信息。

然后我想传递它并触发后续效果。但是我收到的错误是

[ts]
Argument of type '([auth, redirect]: [string, string]) => { type: any; payload: { auth: string; redirect: string; }...' is not assignable to parameter of type '(value: [string, string], index: number) => ObservableInput<{}>'.

Type '{ type: any; payload: { auth: string; redirect: string; }; }' is not assignable to type 'ObservableInput<{}>'.

Type '{ type: any; payload: { auth: string; redirect: string; }; }' is not assignable to type 'Iterable<{}>'.

Property '[Symbol.iterator]' is missing in type '{ type: any; payload: { auth: string; redirect: string; }; }'.

我的效果看起来像这样

  @Effect()
  identityRedirect$ = this.actions$.pipe(
    ofType<ActionWithPayload<any>>(REDIRECT_TO_LOGIN),
    map(action => action.payload),
    map(nonce =>
      combineLatest(
        this.discoverService.returnEndpoint('{identity:api:login}'),
        this.discoverService.returnEndpoint('{self:site}')
      )
    ),
    switchMap(([auth, redirect]: [string, string]) => {
      return { type: SETUP_LOGIN, payload: { auth, redirect } };
    })
  );

如何将这样的电话连接起来?我很难理解我在这里做错了什么。任何帮助将不胜感激。

0 个答案:

没有答案