Skip to content

Commit

Permalink
Fix createObservableContext
Browse files Browse the repository at this point in the history
  • Loading branch information
bigslycat committed Jul 24, 2018
1 parent d649abc commit dabb122
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/react-honeycombs/src/createObservableContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const createObservableContext = <T>(): {|
class Provider extends React.PureComponent<Props<T>, {| value: T |}> {
/* :: subscription: SubscriberSubscription<T>; */

updateObserver = {
next: (value: T): void => {
this.setState({ value });
},
};

componentDidMount() {
this.subscribe();
}
Expand All @@ -42,12 +48,7 @@ export const createObservableContext = <T>(): {|

subscribe() {
const { observable } = this.props;

this.subscription = observable.subscribe(
(value: T): void => {
this.setState({ value });
},
);
this.subscription = observable.subscribe(this.updateObserver);
}

unsubscribe() {
Expand Down

0 comments on commit dabb122

Please sign in to comment.