JSFiddle - React, Tailwind, and code Playground

by vikikamath

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.35/Bacon.min.js"></script>
<a href="#1">A</a>
<a href="#2">B</a>
<a href="#3">C</a>

JavaScript

/*var scoreMultiplier = Bacon.constant(1),
    hitUfo = new Bacon.Bus(),
    hitMotherShip = new Bacon.Bus(), 
    score = Bacon.update(
     0,
  [hitUfo, scoreMultiplier], function(score, _, multiplier) { return score + 100 * multiplier },
  [hitMotherShip], function(score, _) { return score + 2000 }
);

hitUfo.plug(Bacon.interval(1000, Bacon.sequentially(1, [1,2,3])))

score.onValue(function(x){
    console.log(x);
});*/

/*var hitUfo = new Bacon.Bus(),
    hitMotherShip = new Bacon.Bus(), 
    score = Bacon.when(
      [hitUfo], function(score, _) { return score + 33 },
      [hitMotherShip], function(score, _) { return score + 2000 }
    );

hitUfo.plug(Bacon.interval(1000, 1))
hitMotherShip.plug(Bacon.interval(2000, 3))

score.onValue(function(x){
    console.log(x);
});
*/

var analyticsChannel = new Bacon.Bus(),
    hashChangeChannel = new Bacon.Bus(),
    s = screen();
    pattern = Bacon.when(
        [hashChangeChannel], function(h){
            screen().set(h);
            return screen().get();
        },
        [analyticsChannel], function(a){
            return a + "-" + screen().get();
        }
      );

function screen (){
        var scr = "";
           
        return {
            "get": function(){
               return this.scr;   
            }.bind(this),
            "set": function(_sc){
                this.scr = _sc;
            }.bind(this)
        }
    }
analyticsChannel.plug(Bacon.interval(2000, "a"));
hashChangeChannel.plug($('a').asEventStream("click").map(function(e){ return e.currentTarget.hash;}));

pattern.log();


/*var bus = new Bacon.Bus();

bus.plug($('a').asEventStream("click").map(function(e){ return e.currentTarget.hash;}))

bus.log()
*/