Skip to content

Commit

Permalink
refactor: destructure options outside of op func
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed May 20, 2021
1 parent 17dc704 commit 56919fa
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/internal/operators/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
* @return A function that returns an Observable that mirrors the source.
*/
export function share<T>(options: ShareConfig<T> = {}): MonoTypeOperatorFunction<T> {
const { connector = () => new Subject<T>(), resetOnError = true, resetOnComplete = true, resetOnRefCountZero = true } = options;
// It's necessary to use a wrapper here, as the _operator_ must be
// referentially transparent. Otherwise, it cannot be used in calls to the
// static `pipe` function - to create a reusable pipeline.
Expand All @@ -143,8 +144,6 @@ export function share<T>(options: ShareConfig<T> = {}): MonoTypeOperatorFunction
// _operator function_ is called when the complete pipeline is composed - not
// when the static `pipe` function is called.
return (wrapperSource) => {
const { connector = () => new Subject<T>(), resetOnError = true, resetOnComplete = true, resetOnRefCountZero = true } = options;

let connection: SafeSubscriber<T> | null = null;
let resetConnection: Subscription | null = null;
let subject: SubjectLike<T> | null = null;
Expand Down

0 comments on commit 56919fa

Please sign in to comment.