1.0.5 • Published 6 years ago

imstate v1.0.5

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

imstate

An application state management and more

Samples:

    import React from 'react';
    import { render } from 'react-dom';
    import { create } from 'imstate';

    const app = create({
      todos: []
    });
    
    const impureAction = (text) => app(state => state.todos.push({ text }));
    const pureAction = ($state, text) => $state(state => state.todos.push({ text }));
    
    const App = app.component(
      (state, props, { invoke }) => ({ todos: state.todo, invokte }),
      props => {
        const { todos, invoke } = props;
        let input;
        
        function handlePureClick() {
          invoke(pureAction, input.value);
        }
        
        function handleImpureClick() {
          impureAction(input.value)
        }
        
        return (
          <div>
            <input type="text" ref={node => input = node}/>
            <button onClick={handlePureClick}>Pure Action</button>
            <button onClick={handleImpureClick}>Impure Action</button>
            <ul>
                {todos.map((todo, index) => <li key={index}>{todo.text}</li>)}
            </ul>
          </div>
        );
      }
    );
    
    render(<App/>, document.getEleementById('root'));
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago