1.1.2 • Published 8 years ago

mobx-deku v1.1.2

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

mobx-deku

Package with deku component wrapper for combining deku with mobx. Exports the observer function decorator. For documentation, see the mobx project.

npm install mobx-deku

Boilerplate Projects that use mobx-deku

API documentation

observer(component)

Function that converts a Deku component definition or stand-alone render function into a reactive component. See the mobx documentation for more details.

import {observer} from "mobx-deku";

const TodoView = observer({
    render({props}) {
        return <div>{props.todo.title}</div>
    }
}));

Full Example

import {render, tree} from 'deku';
import element from 'magic-virtual-element';
import {observable} from 'mobx';
import {observer} from 'mobx-deku';

class AppState {
  @observable counter = 0;
  increaseCounter () {
    this.counter += 1;
  }
}
const appState = new AppState();

const App = observer({
  render ({props}) {
    return (
      <div>
        <div class='app'>{props.appState.counter}</div>
        <button onClick={onClick}>+</button>
      </div>
    );
    function onClick () {
      props.appState.increaseCounter();
    }
  }
});

render(tree(<App appState={appState} />), document.createElement('div'));

Special thanks to mobx-react and @mattmccray's gist

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago