New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(Operator): replace operator<T, R> to interface #1825
Conversation
I agree this change |
@kwonoj initially I wrote the export class Operator<T, R> {
call(subscriber: Subscriber<R>, source: any): TeardownLogic {
return source._subscribe(subscriber);
}
}
export class Observable<T> implements Subscribable<T> {
/* ... */
subscribe(observerOrNext?: PartialObserver<T> | ((value: T) => void),
error?: (error: any) => void,
complete?: () => void): Subscription {
const sink = toSubscriber(observerOrNext, error, complete);
sink.add(this.operator.call(sink, this));
if (sink.syncErrorThrowable) {
sink.syncErrorThrowable = false;
if (sink.syncErrorThrown) {
throw sink.syncErrorValue;
}
}
return sink;
}
}
Observable.prototype.operator = new Operator<any, any>(); |
Maybe I'm not catching all correctly, is it need all implementation of operator have base classes instead of export interface Operator {
call(...): TearDownLogic
}
class DefaultOperator<any, any> implements Operator {
call(..): { return source._subscribe(...) };
}
export class Observable {
private operator = new DefaultOperator();
} |
@kwonoj yes, or even a private export class Observable {
private operator(source): TeardownLogic {
// `this` refers to the Subscriber, because
// Observable does `this.operator.call(sink, this)`
return source._subscribe(this);
}
} |
68b5cd9
to
ae0c163
Compare
Rebased. I think this change can be checked in and @trxcllnt 's change can follow later. Suggestions? /cc @trxcllnt , @jayphelps |
- remove base implemetation to call(), not being used
ae0c163
to
dd6f3a8
Compare
LGTM |
cool, thanks @jayphelps ! :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
This PR replaces implementation
Operator<T, R>
intointerface
by base implementationOperator::call
is not necessarily needed, since creating new operator requires to override it any time. Instead, this PR makes operator as contract interface only.