Skip to content

Commit a87ac69

Browse files
authored
Merge pull request #626 from aryaemami59/memoizeOptions
2 parents 634ef51 + 9d7290f commit a87ac69

21 files changed

+7218
-4486
lines changed

.eslintrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"array-bracket-spacing": [0],
1313
"comma-dangle": [2, "never"],
1414
"eol-last": 2,
15-
"indent": [2, 2, {
16-
"SwitchCase": 1
17-
}],
1815
"no-multiple-empty-lines": 2,
1916
"object-curly-spacing": [2, "always"],
2017
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],

src/autotrackMemoize/autotrackMemoize.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { createNode, updateNode } from './proxy'
2-
import { Node } from './tracking'
2+
import type { Node } from './tracking'
33

4-
import { createCache } from './autotracking'
54
import {
65
createCacheKeyComparator,
76
defaultEqualityCheck
87
} from '@internal/defaultMemoize'
8+
import type { AnyFunction } from '@internal/types'
9+
import { createCache } from './autotracking'
910

10-
export function autotrackMemoize<F extends (...args: any[]) => any>(func: F) {
11+
export function autotrackMemoize<F extends AnyFunction>(func: F) {
1112
// we reference arguments instead of spreading them for performance reasons
1213

1314
const node: Node<Record<string, unknown>> = createNode(

src/autotrackMemoize/autotracking.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Additional references:
44
// - https://www.pzuraq.com/blog/how-autotracking-works
55
// - https://v5.chriskrycho.com/journal/autotracking-elegant-dx-via-cutting-edge-cs/
6+
import type { EqualityFn } from '@internal/types'
67
import { assert } from './utils'
78

89
// The global revision clock. Every time state changes, the clock increments.
@@ -13,8 +14,6 @@ export let $REVISION = 0
1314
// computing, then the tracker is null.
1415
let CURRENT_TRACKER: Set<Cell<any> | TrackingCache> | null = null
1516

16-
type EqualityFn = (a: any, b: any) => boolean
17-
1817
// Storage represents a root value in the system - the actual state of our app.
1918
export class Cell<T> {
2019
revision = $REVISION

src/autotrackMemoize/proxy.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Original source:
22
// - https://github.com/simonihmig/tracked-redux/blob/master/packages/tracked-redux/src/-private/proxy.ts
33

4+
import type { Node, Tag } from './tracking'
45
import {
56
consumeCollection,
6-
dirtyCollection,
7-
Node,
8-
Tag,
97
consumeTag,
10-
dirtyTag,
11-
createTag
8+
createTag,
9+
dirtyCollection,
10+
dirtyTag
1211
} from './tracking'
1312

1413
export const REDUX_PROXY_LABEL = Symbol()

src/autotrackMemoize/tracking.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import type { Cell } from './autotracking'
12
import {
2-
createCell as createStorage,
33
getValue as consumeTag,
4-
setValue,
5-
Cell
4+
createCell as createStorage,
5+
setValue
66
} from './autotracking'
77

88
export type Tag = Cell<unknown>

0 commit comments

Comments
 (0)