egman24
4/5/2016 - 4:09 PM

Rx Conditionals

Rx Conditionals

  • Rx Conditionals, Branching, Decision
  • Rx choice of what/how to execute

Stay in RX 'functor' (stream context) or drop out and back in...

  <observable that puts out either [] or [ ... keyData ... ]>
  .filter(R.compose(R.not, R.isEmpty))
  
  
  flatmap out of, and back into stream context... patternmatch and use data in closure
  
  
  <observable that puts out either [] or [ ... keyData ... ]>
  .flatMap(R.cond([
    [R.compose(R.not, R.isEmpty), function(keyData){
      return Rx.Observable.just(keyData)
        .take(1)
        .tap(function(keyData){ memoizedKeyData = keyData; })
        .tap(function(){ drawGraphOne(memoizedKeyData) })
        .tap(function(){ drawGraphTwo(memoizedKeyData) })
        .tap(function(){ ACTIONS.publish({ message: 'reportsSection::ready' }) });
    }],
    [R.T, function(keyData){
      return Rx.Observable.just(keyData)
        .tap(function(keyData){ debugger; })
    }]
  ]))
  .subscribe();