Skip to content

Commit

Permalink
Merge pull request #1700 from david-driscoll/fix/1697
Browse files Browse the repository at this point in the history
chore(typings): fixed compiler errors when using @next version of typescript
  • Loading branch information
benlesh committed May 25, 2016
2 parents 3dc1c00 + 88651ee commit a98bec7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
62 changes: 31 additions & 31 deletions src/observable/BoundCallbackObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class BoundCallbackObservable<T> extends Observable<T> {
constructor(private callbackFunc: Function,
private selector: Function,
private args: any[],
public scheduler: Scheduler) {
private scheduler: Scheduler) {
super();
}

Expand All @@ -100,7 +100,7 @@ export class BoundCallbackObservable<T> extends Observable<T> {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
subject.error(errorObject.e);
} else {
} else {
subject.next(result);
subject.complete();
}
Expand All @@ -119,45 +119,45 @@ export class BoundCallbackObservable<T> extends Observable<T> {
}
return subject.subscribe(subscriber);
} else {
return scheduler.schedule(dispatch, 0, { source: this, subscriber });
return scheduler.schedule(BoundCallbackObservable.dispatch, 0, { source: this, subscriber });
}
}
}

function dispatch<T>(state: { source: BoundCallbackObservable<T>, subscriber: Subscriber<T> }) {
const self = (<Subscription> this);
const { source, subscriber } = state;
const { callbackFunc, args, scheduler } = source;
let subject = source.subject;
static dispatch<T>(state: { source: BoundCallbackObservable<T>, subscriber: Subscriber<T> }) {
const self = (<Subscription><any>this);
const { source, subscriber } = state;
const { callbackFunc, args, scheduler } = source;
let subject = source.subject;

if (!subject) {
subject = source.subject = new AsyncSubject<T>();
if (!subject) {
subject = source.subject = new AsyncSubject<T>();

const handler = function handlerFn(...innerArgs: any[]) {
const source = (<any>handlerFn).source;
const { selector, subject } = source;
if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
self.add(scheduler.schedule(dispatchError, 0, { err: errorObject.e, subject }));
const handler = function handlerFn(...innerArgs: any[]) {
const source = (<any>handlerFn).source;
const { selector, subject } = source;
if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
self.add(scheduler.schedule(dispatchError, 0, { err: errorObject.e, subject }));
} else {
self.add(scheduler.schedule(dispatchNext, 0, { value: result, subject }));
}
} else {
self.add(scheduler.schedule(dispatchNext, 0, { value: result, subject }));
const value = innerArgs.length === 1 ? innerArgs[0] : innerArgs;
self.add(scheduler.schedule(dispatchNext, 0, { value, subject }));
}
} else {
const value = innerArgs.length === 1 ? innerArgs[0] : innerArgs;
self.add(scheduler.schedule(dispatchNext, 0, { value, subject }));
}
};
// use named function to pass values in without closure
(<any>handler).source = source;
};
// use named function to pass values in without closure
(<any>handler).source = source;

const result = tryCatch(callbackFunc).apply(this, args.concat(handler));
if (result === errorObject) {
subject.error(errorObject.e);
const result = tryCatch(callbackFunc).apply(this, args.concat(handler));
if (result === errorObject) {
subject.error(errorObject.e);
}
}
}

self.add(subject.subscribe(subscriber));
self.add(subject.subscribe(subscriber));
}
}

interface DispatchNextArg<T> {
Expand Down
9 changes: 6 additions & 3 deletions src/observable/FromEventObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ export class FromEventObservable<T, R> extends Observable<T> {
FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber);
}
} else if (isEventTarget(sourceObj)) {
const source = sourceObj;
sourceObj.addEventListener(eventName, <EventListener>handler);
unsubscribe = () => sourceObj.removeEventListener(eventName, <EventListener>handler);
unsubscribe = () => source.removeEventListener(eventName, <EventListener>handler);
} else if (isJQueryStyleEventEmitter(sourceObj)) {
const source = sourceObj;
sourceObj.on(eventName, handler);
unsubscribe = () => sourceObj.off(eventName, handler);
unsubscribe = () => source.off(eventName, handler);
} else if (isNodeStyleEventEmmitter(sourceObj)) {
const source = sourceObj;
sourceObj.addListener(eventName, handler);
unsubscribe = () => sourceObj.removeListener(eventName, handler);
unsubscribe = () => source.removeListener(eventName, handler);
}

subscriber.add(new Subscription(unsubscribe));
Expand Down
4 changes: 2 additions & 2 deletions src/operator/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class StaticArrayIterator<T> implements LookAheadIterator<T> {
next(value?: any): IteratorResult<T> {
const i = this.index++;
const array = this.array;
return i < this.length ? { value: array[i], done: false } : { done: true };
return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
}

hasValue() {
Expand Down Expand Up @@ -279,7 +279,7 @@ class ZipBufferIterator<T, R> extends OuterSubscriber<T, R> implements LookAhead
next(): IteratorResult<T> {
const buffer = this.buffer;
if (buffer.length === 0 && this.isComplete) {
return { done: true };
return { value: null, done: true };
} else {
return { value: buffer.shift(), done: false };
}
Expand Down

0 comments on commit a98bec7

Please sign in to comment.