These are chat archives for pozadi/kefir

24th
Feb 2016
Sergey Lapin
@lapanoid
Feb 24 2016 11:43

@rpominov hi sadly have not been here for a while.. I am trying to understand your general approach on controlling streams. Looks like kefir don't have resume/pause methods like highland have f.e. http://highlandjs.org/#pause . And because emmiter is kinda hidden right now, to force user write in FP style I assume I am running into really ugly code

const streamController = (stream)=>{
  let enable = true;
  let emitter;
  const outStream = Kefir.stream(_emitter => {
    emitter = _emitter;
  });

  stream.onValue((val)=>{
    if(!enable){
      return;
    }
    emitter.emit(val);
  })

  return {
    setEnable: (_enable)=>{
      enable = _enable
    },
    stream: outStream
  }
}

Could you comment on this?

Roman Pominov
@rpominov
Feb 24 2016 12:21

Hi @lapanoid glad you're back :)

Will it make sense to simply unsubscribe on the consumer side when it don't want to see updates?

The solutions here depends on how (from where) you call setEnable
If it on consumer side, it can probably just unsubscribe
If it on source side, I would try to express enable as a stream, and then use .filterBy
Sergey Lapin
@lapanoid
Feb 24 2016 12:32
Thanks, I guess my case is on source side so filterBy fits perfectly
Just forgot that in frp anything is a stream :cold_sweat: