0

I have a subject that wraps a WebSocket (https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/doc/operators/fromwebsocket.md) and I want to buffer messages received by the WebSocket. I've looked at https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/buffer.md but an observable is used instead of a subject. Also, I've read that subjects can be used to use buffering or caching "You can use subjects to implement a custom observable with caching, buffering and time shifting" (https://xgrommx.github.io/rx-book/content/getting_started_with_rxjs/subjects.html), how can I use the subject and observers to implement that sort of things (buffering, caching, ...).

I'm a little bit los with the concepts of Rx, they are more difficult than akka-streams!!

Thanks,

vicaba
  • 2,836
  • 1
  • 27
  • 45
  • 1
    Why can you not use an `Observable`? A `Subject` is really just an object that implements both the `Observable and Observer` interfaces, so buffering on one is buffering on the other. – paulpdaniels Jul 06 '16 at 16:44
  • @paulpdaniels yeahh, just realised that a few moments ago... I was doing it correctly but for some reason I didn't realise that I was printing e.data and buffering changes the variable type to an array, so data was undefined and I got stuck in that.... – vicaba Jul 06 '16 at 16:56

0 Answers0