Skip to content

Commit

Permalink
perf(fromDOM): use bind operator instead of closure
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Feb 4, 2017
1 parent 6cfb25b commit 6a06596
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sources/FromDOM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import {Observable} from '../types/core/Observable'
import {Observer} from '../types/core/Observer'
import {Scheduler} from '../types/Scheduler'
import {Subscription} from '../types/core/Subscription'
import {IListener} from '../types/IListener'
import {Curry} from '../lib/Curry'
Expand All @@ -25,8 +24,8 @@ class DOMObservable implements TResult {
constructor (private name: string, private element: HTMLElement) {
}

subscribe (observer: Observer<Event>, scheduler: Scheduler): Subscription {
const listener = (e: Event) => observer.next(e)
subscribe (observer: Observer<Event>): Subscription {
const listener = observer.next.bind(observer)
this.element.addEventListener(this.name, listener)
return new DOMSubscription(this.element, listener, this.name)
}
Expand Down

0 comments on commit 6a06596

Please sign in to comment.