2.1.0 • Published 10 years ago

oro-dispatcher v2.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
10 years ago

dispatcher

NOTE The javascript exported in this module is written as es6 modules. You will probably need to transpile it to make it work. Tip for React folks: 6to5-loader for webpack does jsx as well by default.

Actions

// Counter/actions.js

import send from "oro-dispatcher/send";

export default {
  // ...
  inc(uuid) { send("COUNTER_INC", {uuid}) }
  // ...
};

Store

// Counters/store.js

import store from "oro-dispatcher/store";

var __counters = {
  "asdf" : {uuid: "asdf", count: 4, label: "foo"},
  "woot" : {uuid: "woot", count: 5, label: "bar"}
}

export default store("COUTNER", {

  getCounters() { return __counters; }

}, function(paylaod) {
  let {actionType, uuid} = paylaod.action;

  switch (actionType) {
    // ...

    case "COUNTER_INC":
      __counters[uuid] = __counters[uuid] + 1;
      this.broadcast();
      break;

    // ...
  }
});

Component

// Counters/index.js

import React from "react";
import sub   from "oro-dispatcher/sub";
import store from "./store";

function state() {
  return {
    counters: store.getCounters()
  };
}

export default React.createClass({
  mixins: [sub(state, store)],

  render() {
    let {counters} = this.state;

    return <div>
      {counters.map(d => <Counter {...d}/>)}
    </div>
  }
});
2.1.0

10 years ago

2.0.0

10 years ago

1.3.4

10 years ago

1.3.3

10 years ago

1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.7

11 years ago

1.0.6

11 years ago

1.0.5

11 years ago

1.0.4

11 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago