-
Notifications
You must be signed in to change notification settings - Fork 3k
Add smaller operator creation function. #5739
Copy link
Copy link
Closed
Description
This work is blocked on finishing #5729 reviews and landing it... but the crux of it is simple enough... this pattern exists in all operators:
export function someOperator<A, B>(...args: any[]): OperatorFunction(A, B) {
return (source: Observable<A>) => lift(source, function (this: Subscriber<B>, liftedSource: Observable<A>) {
// Do things here and maybe return teardown.
});
}The idea is to go through and replace the return here with a helper that does this wiring for us:
function operate<A, B>(init: (subscriber: Subscriber<B>, liftedSource: Observable<A>) => TeardownLogic) {
return (source: Observable<A>) => wrappedLift(source, init);
}usage:
export function someOperator<A, B>(...args: any[]): OperatorFunction(A, B) {
return operate((subscriber, liftedSource) => {
// Do things here and maybe return teardown.
});
}Then use it in each operator to further reduce size. It may also help with readability? Either way, comments will be required.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels