Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    dwfluxpublic

    dawee's Flux

    Yet another Flux lib based on facebook Emitter/Dispatcher.

    Installation

    npm install dwflux
    

    Usage

    Create an Action

    const Action = require('dwflux/action');
     
    const clickOnStuff = Action.create((evt, done) => {
      done(null, {
        x: evt.nativeEvent.screenX,
        y: evt.nativeEvent.screenY
      });
    });

    Trigger an Action

      onMouseClick(evt) {
        clickOnStuff(evt);
      }

    Create a Store

    const Store = require('dwflux/store');
     
    class SelectionStore extends Store {
      
      constructor() {
        super();
        this.register(clickOnStuff, this.selectStuff);
      }
     
      selectStuff(opts) {
        this.selection = {x: opts.x, y: opts.y}
        this.emit('change');
      }
    }

    Listen to Store changes

    const selectionStore = new SelectionStore();
     
    selectionStore.on('change', function () {
      // Update your view/component here
    });

    Keywords

    none

    install

    npm i dwflux

    Downloadsweekly downloads

    18

    version

    0.0.8

    license

    ISC

    repository

    githubgithub

    last publish

    collaborators

    • avatar