Skip to content

Commit

Permalink
[fixed] binding on IndefiniteSubject operators
Browse files Browse the repository at this point in the history
Summary:
Otherwise, this wouldn't work, because `this` would get rebound:

```
element.addEventListener(eventType, subject.next)
```

Reviewers: O3 Material JavaScript platform reviewers, #material_motion, O2 Material Motion, featherless

Reviewed By: #material_motion, O2 Material Motion, featherless

Tags: #material_motion

Differential Revision: http://codereview.cc/D2521
  • Loading branch information
appsforartists committed Jan 23, 2017
1 parent 85a530a commit 886790e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/streams/src/observables/IndefiniteSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class IndefiniteSubject<T> implements Observable<T>, Observer<T> {
* observer `subscribe`s before `next` is called again, it will immediately
* receive `value`.
*/
next(value: T) {
next = (value: T) => {
this._hasStarted = true;
this._lastValue = value;

Expand All @@ -65,7 +65,7 @@ export class IndefiniteSubject<T> implements Observable<T>, Observer<T> {
* Call the returned `unsubscribe` method to stop receiving values on this
* particular observer.
*/
subscribe(observerOrNext: ObserverOrNext<T>): Subscription {
subscribe = (observerOrNext: ObserverOrNext<T>): Subscription => {
const observer = wrapWithObserver<T>(observerOrNext);

this._observers.add(observer);
Expand All @@ -86,7 +86,7 @@ export class IndefiniteSubject<T> implements Observable<T>, Observer<T> {
*
* https://github.com/tc39/proposal-observable#observable
*/
[$$observable](): Observable<T> {
[$$observable] = (): Observable<T> => {
return this;
}
}
Expand Down

0 comments on commit 886790e

Please sign in to comment.