2017-05-14 34 views
0
@Effect() 
    results$ = this.actions$ 
    .ofType(SearchActions.Action_X) 
    .map(Operation_OP) 
    .do(conole.log);//<=payload of type X 
    .map(....) 

    @Effect() 
    results$ = this.actions$ 
    .ofType(SearchActions.Action_X) 
    .map(Operation_OP) 
    .do(conole.log);//<=payload of type Y 
    .map(....) 

我需要有條件的分支來做不同的操作,基於某些operaton的返回值,但我需要將結果存儲在相同的結果中$(上面的代碼會因爲結果$聲明兩次而出錯,請建議正確的方式來實現這一目標)如何基於數據的返回類型來分支ngrx效果鏈?

This不回答我的問題是基於行動,我的情況下,它的分支同樣的動作Action_X到intiate鏈,但連續的步驟需要根據twhat是不同的返回

回答

0
@Effect() 
    results$ = this.actions$ 
    .ofType(SearchActions.Action_X) 
    .map(action => { 
     result = operation(); 
     if (result === 1) { 
      return 1; 
     } else { 
      return 2; 
     } 
    } 
);