@cascateer/core 2.2.0 → 2.2.1

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.2.0",
3
+ "version": "2.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
package/src/api.ts CHANGED
@@ -4,9 +4,7 @@ import {
4
4
  intersectionWith,
5
5
  isEqual,
6
6
  isFunction,
7
- memoize,
8
7
  } from "lodash";
9
- import objectHash from "object-hash";
10
8
  import {
11
9
  combineLatest,
12
10
  filter,
@@ -22,6 +20,7 @@ import {
22
20
  UnaryFunction,
23
21
  } from "rxjs";
24
22
  import { asObservable, ExtendableDictionary, property } from "./lib";
23
+ import { memoizeHashed } from "./lib/memoizeHashed";
25
24
  import { ProxyObservable } from "./observable";
26
25
  import { Action, MaybeArray, MaybeObservable, ProxyEffect } from "./types";
27
26
 
@@ -48,7 +47,7 @@ class Memoizable<Args, Result> {
48
47
  this.tags = isFunction(tags) ? tags : constant([tags ?? []].flat());
49
48
 
50
49
  this.subscribe = (invalidatedTags) => {
51
- const memoizedEffect: ProxyEffect<Args, Result> = memoize(
50
+ const memoizedEffect: ProxyEffect<Args, Result> = memoizeHashed(
52
51
  (args) =>
53
52
  new ProxyObservable((pending) =>
54
53
  this.predicate(args).pipe(
@@ -72,7 +71,6 @@ class Memoizable<Args, Result> {
72
71
  shareReplay({ bufferSize: 1, refCount: false }),
73
72
  ),
74
73
  ),
75
- (args) => objectHash(args ?? null),
76
74
  );
77
75
 
78
76
  return memoizedEffect;
@@ -0,0 +1,5 @@
1
+ import { memoize } from "lodash";
2
+ import objectHash from "object-hash";
3
+
4
+ export const memoizeHashed = <T extends (...args: any) => any>(func: T) =>
5
+ memoize(func, (...args: Parameters<T>) => objectHash(args ?? null));
package/src/types.ts CHANGED
@@ -2,6 +2,7 @@ import { Dictionary, mapValues, tap } from "lodash";
2
2
  import { combineLatest, ReplaySubject, switchMap, UnaryFunction } from "rxjs";
3
3
  import { Observable } from "rxjs/internal/Observable";
4
4
  import { ObservableInput } from "rxjs/internal/types";
5
+ import { memoizeHashed } from "./lib/memoizeHashed";
5
6
  import { ProxyObservable } from "./observable";
6
7
  import { concat, every, some } from "./operators";
7
8
 
@@ -34,15 +35,15 @@ export class ProxyEffectInterceptor extends ReplaySubject<
34
35
  intercept<Effects extends Dictionary<ProxyEffect<any, any>>>(
35
36
  effects: Effects,
36
37
  ): ProxyEffects<Effects> {
37
- return mapValues(
38
- effects,
39
- (effect) => (args) =>
38
+ return mapValues(effects, (effect) =>
39
+ memoizeHashed((args) =>
40
40
  tap(
41
41
  new ProxyObservable(effect(args), (target, receiver) =>
42
42
  combineLatest([target.pending, receiver.refCount]).pipe(every()),
43
43
  ),
44
44
  (source) => this.next(source),
45
45
  ),
46
+ ),
46
47
  );
47
48
  }
48
49