Skip to content

Commit ff56611

Browse files
committed
Add getAtom to Dispatcher API
1 parent a1b4d26 commit ff56611

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Dispatcher.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export default class Dispatcher {
3333
: this.dispatch(action);
3434
}
3535

36+
getAtom() {
37+
return this.atom;
38+
}
39+
3640
setAtom(atom) {
3741
this.atom = atom;
3842
this.emitChange();

src/components/Provider.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { PropTypes } from 'react';
22

33
const dispatcherShape = PropTypes.shape({
44
subscribe: PropTypes.func.isRequired,
5-
perform: PropTypes.func.isRequired
5+
perform: PropTypes.func.isRequired,
6+
getAtom: PropTypes.func.isRequired
67
});
78

89
export default class Provider {
@@ -41,6 +42,10 @@ export default class Provider {
4142
return this.props.dispatcher.perform(actionCreator, ...args);
4243
}
4344

45+
getAtom() {
46+
return this.props.dispatcher.getAtom();
47+
}
48+
4449
render() {
4550
const { children } = this.props;
4651
return children();

src/createDispatcher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export default function createDispatcher(...args) {
88
perform: ::dispatcher.perform,
99
hydrate: ::dispatcher.hydrate,
1010
dehydrate: ::dispatcher.dehydrate,
11+
getAtom: ::dispatcher.getAtom
1112
};
1213
}

0 commit comments

Comments
 (0)