JSFiddle - React, Tailwind, and code Playground

by vikikamath

HTML

<script src="https://rpominov.github.io/kefir/dist/kefir.js"></script>

JavaScript

/*function KefirBus(){
    var emitter;
    var stream = Kefir.stream(function(_emitter){
        
        return function() {
            emitter = undefined;   
        };
    });
    
    stream.emitEvent = function(event) {
        if (event.type === 'end') {
           this.end();   
        } else {
          if (emitter) emitter.emitEvent(event);   
        }
        return this;
    }
    return stream;
}

var b1 = new KefirBus();

b1.emitEvent({
    type: 'value',
    value: 1
});*/

var a = Kefir.sequentially(100, [0, 1, 2]);
var b = Kefir.sequentially(500, ['+', '_', '=']);
var c = Kefir.sequentially(100, ['a', 'b', 'c']);
var z1 = Kefir.combine([a, b]);
var z2 = Kefir.combine([a, c]);
var z3 = Kefir.combine([b, c]);

var priority = [ 'z2', 'z1', 'z3'];


//var result = z3.flatMapLatest(function(){ return z2;}); // z3 has higher priority
var result = Kefir.combine([z1, z2, z3], function(z1, z2, z3) {
        console.log(z1);
        console.log(z2);
        console.log(z3);
        
    });

result.log();