Skip to content

Commit

Permalink
Add getAtom to Dispatcher API
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jun 6, 2015
1 parent a1b4d26 commit ff56611
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default class Dispatcher {
: this.dispatch(action);
}

getAtom() {
return this.atom;
}

setAtom(atom) {
this.atom = atom;
this.emitChange();
Expand Down
7 changes: 6 additions & 1 deletion src/components/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { PropTypes } from 'react';

const dispatcherShape = PropTypes.shape({
subscribe: PropTypes.func.isRequired,
perform: PropTypes.func.isRequired
perform: PropTypes.func.isRequired,
getAtom: PropTypes.func.isRequired
});

export default class Provider {
Expand Down Expand Up @@ -41,6 +42,10 @@ export default class Provider {
return this.props.dispatcher.perform(actionCreator, ...args);
}

getAtom() {
return this.props.dispatcher.getAtom();
}

render() {
const { children } = this.props;
return children();
Expand Down
1 change: 1 addition & 0 deletions src/createDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default function createDispatcher(...args) {
perform: ::dispatcher.perform,
hydrate: ::dispatcher.hydrate,
dehydrate: ::dispatcher.dehydrate,
getAtom: ::dispatcher.getAtom
};
}

0 comments on commit ff56611

Please sign in to comment.