Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dva & choo & elm

dvajs

https://github.com/dvajs/dva#dva

https://github.com/dvajs/dva/blob/master/README_zh-CN.md

choo

https://github.com/yoshuawuyts/choo

https://choo.io/

✌️

    
let html = require('choo/html'),
    choo = require('choo'),
    app = choo();

app.use(titleStore);
app.route('/', mainView);
app.mount('body');

const mainView = (state, emit) => {
    let update = (e) => {
        emit('update', e.target.value);
    };
    return html `
        <body>
        <h1>Title: ${state.title}</h1>
        <input type="text" value="${state.title}" oninput=${update}>
        </body>
    `;
};

const titleStore = (state, emitter) => {
    state.title = 'Not quite set yet';
    emitter.on('DOMContentLoaded', function () {
        emitter
            .on('update', function (newTitle) {
                state.title = newTitle;
                emitter.emit('render');
            })
    });
};

elm

http://elm-lang.org/

@xyzdata

This comment has been minimized.

Copy link
Owner Author

@xyzdata xyzdata commented Jun 29, 2017

let html = require('choo/html'),
    choo = require('choo'),
    app = choo();

app.use(titleStore);
app.route('/', mainView);
app.mount('body');

const mainView = (state, emit) => {
    let update = (e) => {
        emit('update', e.target.value);
    };
    return html `
        <body>
            <h1>Title: ${state.title}</h1>
            <input type="text" value="${state.title}" oninput=${update}>
        </body>
    `;
};

const titleStore = (state, emitter) => {
    state.title = 'Not quite set yet';
    emitter.on('DOMContentLoaded', () => {
        emitter.on('update', (newTitle) => {
            state.title = newTitle;
            emitter.emit('render');
        });
    });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment