JSFiddle - React, Tailwind, and code Playground

by gianlucaguarini

HTML

<script src="https://rawgit.com/baconjs/bacon.js/master/dist/Bacon.js"></script>

JavaScript

var Model = function (initialData) {

    this.stream = new Bacon.Bus();

    this.bind = function (model) {

        this.stream.assign(model,'set');
        // double way binding
        model.stream.assign(this,'set');

    };
    
    this.set = function (newData) {
        if (newData === this.data) return;
        this.data = newData;
        this.stream.push(this.data);
    }
    
    // debugger
    //this.stream.log();
    this.set(initialData);
    
    return this;

};

var model = new Model('bar'),
    i = 5000;

while (i--) {
    model.bind(new Model('foo'));
}

model.set('whatever');