‚̧Nearly Perfect Mediocracy
    Have ideas to improve npm?Join in the discussion! ¬Ľ

    imstate

    1.0.5¬†‚Äʬ†Public¬†‚Äʬ†Published

    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'));

    Install

    npm i imstate

    DownloadsWeekly Downloads

    2

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    38.7 kB

    Total Files

    13

    Last publish

    Collaborators

    • avatar