2017-06-21 10 views
0

、「サインアップ成功」をサインアップするとき、私はこのReduxの-観測mergeMapワット/ 2出力

/** 
* Request a new account from the API 
*/ 
export function signupApiRequest(action$: Observable, store: Store) { 
    return action$.ofType(SIGNUP) 
    .map(action => [ action, store.getState().accounts.signup ]) 
    .mergeMap(([ action, signup ]) => 
     sendCommand('/api/accounts/signup', { 
      name: signup.name, 
      email: signup.email 
     }) 
     .map(response => [ response, signup.email ]) 
    ) 
    .mergeMap(([ response, email ]) => { 
     switch (response.status) { 
     case 409: 
      return [existingUser(email)]; 

     case 201: 
      const succ = { type: successOf(SIGNUP) }, 
       user = mapTokenToUser(response.body.data), 
       created = userCreated(user); 
      console.log('signup success', [succ, created]); 
      return [succ, created]; 

     default: 
      throw new Error(`Unknown response code ${response.code}`); 
     } 
    }); 
} 

のような叙事詩を持っているが印刷されており、彼らが必要として、両方のアクションが記録されます。

ただし、最初のアクションのみが叙事詩から出力されます。 Redux actions for realz

なぜ、私は間違っていますか?

配列の順序を変更すると、もう一方の値が出力されます。

+0

ます。https:// githubの.com/redux-observable/redux-observable/issues/263 – Henrik

答えて

1

これは、5.1.0で始まるRxJS自体のバグであることがわかりました。あなたのレデューサーには例外がスローされますが、RxJSによって黙って飲み込まれています。それが再来/ Reduxの-観測可能と対話していますどのように

https://github.com/redux-observable/redux-observable/issues/263#issuecomment-310180351

少し複雑ですが、これはで再現できるよう、最終的には関係ありません:

https://jsbin.com/dukixu/edit?html,js,output

const input$ = new Rx.Subject(); 

input$ 
    .mergeMap(() => Rx.Observable.of(1, 2)) 
    .subscribe(d => { 
    throw new Error('some error'); 
    }); 

input$.next();