Skip to content

Commit

Permalink
Fix mapPropsStream
Browse files Browse the repository at this point in the history
  • Loading branch information
bigslycat committed Jul 24, 2018
1 parent dabb122 commit 7219d17
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/react-honeycombs/src/mapPropsStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ObservableTransform<P, R> = (
) => ObservableInterface<R>;

function callNext<T>(observer: SubscriptionObserver<T>) {
console.log(observer, this);
observer.next(this);
}

Expand All @@ -31,13 +32,20 @@ export const mapPropsStream = <P: {}, R: {}>(
propsObservable: Observable<P>;
stateObservable: ObservableInterface<R>;
subscription: SubscriberSubscription<R>;
updateObserver: {| next(R): void |};
*/

constructor(props, context) {
super(props, context);

this.propsObservers = new Set();

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

this.propsObservable = new Observable(subscriptionObserver => {
this.propsObservers.add(subscriptionObserver);
return () => {
Expand All @@ -61,12 +69,7 @@ export const mapPropsStream = <P: {}, R: {}>(
}

subscribe() {
this.subscription = this.stateObservable.subscribe(
(value: R): void => {
this.setState(value);
},
);

this.subscription = this.stateObservable.subscribe(this.updateObserver);
this.pushProps(this.props);
}

Expand All @@ -80,6 +83,7 @@ export const mapPropsStream = <P: {}, R: {}>(
}

render() {
console.log(this.state);
return this.state && <Component {...this.state} />;
}
};

0 comments on commit 7219d17

Please sign in to comment.