0

I'm been learning how to use JavaScript 'node-style' streams using Bacon.js. Namely, I've been looking at the Bus EventStreams.

It all looks very interesting and I'm sure that JavaScript streams have a multitude of great use cases, but I can't seem to think of a single practical application.

Can anyone provide me with some examples of use cases for Streams?

Adam McKenna
  • 2,295
  • 6
  • 30
  • 41

1 Answers1

1

I used it to handle key events, update values in near real time via Server Side Push/Web socket, and combine with other events to determine a behavior to act upon (ex. if the page has focus when a web socket event fires, update a field..).

Here are a few more...

  • Determine if user is active on a page -

    var blur = $(window).asEventStream('blur').map(function() { return false; });
    var focus = $(window).asEventStream('focus').map(function() { return true; }); 
    var focused = focus.merge(blur).toProperty(true);
    

via http://blog.flowdock.com/2013/01/22/functional-reactive-programming-with-bacon-js/

TypeAhead - See movie search example at https://baconjs.github.io/

Registration Form, Shopping Cart - see https://baconjs.github.io/tutorials.html

Handling Web Socket Connections/Events - http://blog.carbonfive.com/2014/09/23/bacon-js-node-js-mongodb-functional-reactive-programming-on-the-server/ and https://medium.com/@garychambers108/functional-reactive-react-js-b04a8d97a540

Bless Yahu
  • 1,331
  • 1
  • 12
  • 25