@cascateer/core 2.1.30 → 2.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.1.30",
3
+ "version": "2.1.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
@@ -20,14 +20,14 @@ export class ProxyObservable<
20
20
 
21
21
  constructor(
22
22
  target: U | ((pending: NextObserver<boolean>) => U),
23
- pendingFactory?: UnaryFunction<U, Observable<boolean>>,
23
+ handler?: (target: U, receiver: ProxyObservable<T>) => Observable<boolean>,
24
24
  ) {
25
25
  const subscribers = new ReplaySubject<
26
26
  UnaryFunction<Set<Subscriber<T>>, void>
27
27
  >();
28
28
 
29
29
  const pending = new BehaviorSubject(false);
30
- const source = once(() =>
30
+ const memoizedTarget = once(() =>
31
31
  isObservable(target) ? target : target(pending),
32
32
  );
33
33
 
@@ -38,7 +38,7 @@ export class ProxyObservable<
38
38
  subscribers.next((subscribers) => subscribers.delete(subscriber)),
39
39
  );
40
40
 
41
- return source().subscribe(subscriber);
41
+ return memoizedTarget().subscribe(subscriber);
42
42
  });
43
43
 
44
44
  this.pending = pending;
@@ -47,6 +47,6 @@ export class ProxyObservable<
47
47
  map((subscribers) => subscribers.size),
48
48
  );
49
49
 
50
- pendingFactory?.call(null, source()).subscribe(pending);
50
+ handler?.call(null, memoizedTarget(), this).subscribe(pending);
51
51
  }
52
52
  }
@@ -12,4 +12,3 @@ export {
12
12
  } from "./multicast";
13
13
  export { proxyReplaySubject } from "./proxyReplaySubject";
14
14
  export { sequence } from "./sequence";
15
- export { tapSubscription } from "./tapSubscription";
package/src/types.ts CHANGED
@@ -45,8 +45,8 @@ export class ProxyEffectInterceptor extends ReplaySubject<
45
45
  return mapValues(effects, (effect) =>
46
46
  memoizeHashed((args) =>
47
47
  tap(
48
- new ProxyObservable(effect(args), (target) =>
49
- combineLatest([target.pending, target.refCount]).pipe(
48
+ new ProxyObservable(effect(args), (target, receiver) =>
49
+ combineLatest([target.pending, receiver.refCount]).pipe(
50
50
  map((values) => values.every(Boolean)),
51
51
  ),
52
52
  ),
@@ -1,14 +0,0 @@
1
- import { MonoTypeOperatorFunction, NextObserver, tap } from "rxjs";
2
-
3
- export const tapSubscription =
4
- <T>(observer?: NextObserver<boolean>): MonoTypeOperatorFunction<T> =>
5
- (source) => {
6
- let subscriptions = 0;
7
-
8
- return source.pipe(
9
- tap({
10
- subscribe: () => observer?.next(++subscriptions > 0),
11
- unsubscribe: () => observer?.next(--subscriptions > 0),
12
- }),
13
- );
14
- };