Type 0 in the first box, 1 in the second, 2 in the third, etc.

After making a few boxes, try changing any one of the boxes to see what happens

Behaviors are basically reactive variables. The magic part (marked Magic!) is that whenever K.sampleB detects that the behavior changes, it undos all the actions after it. Created behaviors are destroyed, appended elements are removed, event are unlistened, etc. This is what allows reactivity.

Incidentally, we are able to a whole application after starting it. Give it a try.

As for the library, sorry, no releases yet.

The code is as follows:

K = Kagome;

const output = document.getElementById('output');

function createInput() {
    const inputE = document.createElement('input');
    return K.registerB(inputE.value).then(inputB =>  // Creates a new Behavior
        K.listen(inputE, 'input',                    // Change the behavior when input changes
            () => inputB.changeValue(inputE.value)).then(() =>
        K.appendChild(output, inputE).then(() =>     // Put the element into output
        K.pure([inputE, inputB]))));

function game(i) {
    return createInput().then(([inputE, inputB]) =>
        K.sampleB(window.ib = inputB).then(val => { // Magic!
            console.log('blah', val);
            if (val == i.toString())
                return game(i + 1);                 // Recursion is fun!
                return K.pure(undefined);

const app = game(0);

const trace = app.run(() => null);

document.getElementById('destroy').onclick = () => trace.dispose();