0.2.0 • Published 8 years ago

caliburne v0.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Caliburne

Description

This library is a mizchi/flumpt porting for dekujs/deku.

Source code for this library is based from mizchi/flumpt, and flumpt is under the MIT-license.

Example

/** @jsx element */

import { element, dom } from 'deku';
import caliburne from '../src/caliburne';

const { createRenderer } = dom;

const ButtonClickr = {
  render({ props, children, dispatch }) {
    const onClick = () => {
      dispatch('increment');
    };

    return (
      <div>
        <p>{props.count.toString()}</p>
        <p><button onClick={onClick}>Click!</button></p>
      </div>
    );
  },
};

const initialState = { count: 0 };
const context      = caliburne(initialState, [
  (state) => {
    console.log(state);
    return state;
  }
]);

context.on('increment', () => {
  context.update(({ count }) => {
    return { count: count + 1 };
  })
});

const render = createRenderer(document.querySelector('main'), context.dispatch);

context.on(':apply-updating', (state) => {
  render(<ButtonClickr {...state} />, context);
});

Middlewares

Middleware archtecture is (maybe) same as flumpt's middlewares.

TypeScript?

I have no skills for TypeScript.

So, THIS LIBRARY IS NOT INCLUDES .d.ts FILE.

Author

Original implementation is writte by mizchi and that library is under the MIT-license.

This library is written by Naoki OKAMURA (Nyarla) nyarla@thotep.net

License

MIT