Skip to content

Commit

Permalink
build: variable used before declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Aug 31, 2018
1 parent e94dfdc commit 1fcfbad
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const toPromise = <T>(observable: Observable<T>, signal?: AbortSignal): P
reject(createAbortError())
return
}
let subscription: Subscription
const listener = () => {
subscription.unsubscribe()
reject(createAbortError())
Expand All @@ -49,7 +50,7 @@ export const toPromise = <T>(observable: Observable<T>, signal?: AbortSignal): P
}
}
let value: T
const subscription = observable.subscribe(
subscription = observable.subscribe(
val => {
value = val
},
Expand Down Expand Up @@ -77,6 +78,7 @@ export const forEach = <T>(source: Observable<T>, next: (value: T) => void, sign
reject(createAbortError())
return
}
let subscription: Subscription
const listener = () => {
subscription.unsubscribe()
reject(createAbortError())
Expand All @@ -86,9 +88,6 @@ export const forEach = <T>(source: Observable<T>, next: (value: T) => void, sign
signal.removeEventListener('abort', listener)
}
}
// Must be declared in a separate statement to avoid a RefernceError when
// accessing subscription below in the closure due to Temporal Dead Zone.
let subscription: Subscription
subscription = source.subscribe(
value => {
try {
Expand Down

0 comments on commit 1fcfbad

Please sign in to comment.