Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const controller = Controller(Model({}));
- function setFoo({ input, state }) {
- state.set('example.foo', input.value);
- }
- const changeInput = [setFoo];
- const Module = (options = {}) => {
- return (module, controller) => {
- module.addState({
- foo: "original value"
- });
- module.addSignals({
- changeInput
- });
- };
- };
- controller.addModules({
- example: Module()
- })
- @Cerebral({
- display: ['example', 'foo']
- })
- class InputControl extends React.Component {
- render() {
- return (
- <div>
- <input type="text" value={ this.props.display }
- onChange={ (e) => { this.props.signals.example.changeInput.sync({ value: e.target.value }); } }
- />
- </div>
- );
- }
- };
- ReactDOM.render(
- (
- <Container controller={controller}>
- <InputControl/>
- </Container>
- ),
- document.getElementById('root')
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement