Skip to content

Commit

Permalink
Merge pull request #626 from aryaemami59/memoizeOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Oct 28, 2023
2 parents 634ef51 + 9d7290f commit a87ac69
Show file tree
Hide file tree
Showing 21 changed files with 7,218 additions and 4,486 deletions.
3 changes: 0 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"array-bracket-spacing": [0],
"comma-dangle": [2, "never"],
"eol-last": 2,
"indent": [2, 2, {
"SwitchCase": 1
}],
"no-multiple-empty-lines": 2,
"object-curly-spacing": [2, "always"],
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
Expand Down
7 changes: 4 additions & 3 deletions src/autotrackMemoize/autotrackMemoize.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { createNode, updateNode } from './proxy'
import { Node } from './tracking'
import type { Node } from './tracking'

import { createCache } from './autotracking'
import {
createCacheKeyComparator,
defaultEqualityCheck
} from '@internal/defaultMemoize'
import type { AnyFunction } from '@internal/types'
import { createCache } from './autotracking'

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

const node: Node<Record<string, unknown>> = createNode(
Expand Down
3 changes: 1 addition & 2 deletions src/autotrackMemoize/autotracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Additional references:
// - https://www.pzuraq.com/blog/how-autotracking-works
// - https://v5.chriskrycho.com/journal/autotracking-elegant-dx-via-cutting-edge-cs/
import type { EqualityFn } from '@internal/types'
import { assert } from './utils'

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

type EqualityFn = (a: any, b: any) => boolean

// Storage represents a root value in the system - the actual state of our app.
export class Cell<T> {
revision = $REVISION
Expand Down
9 changes: 4 additions & 5 deletions src/autotrackMemoize/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Original source:
// - https://github.com/simonihmig/tracked-redux/blob/master/packages/tracked-redux/src/-private/proxy.ts

import type { Node, Tag } from './tracking'
import {
consumeCollection,
dirtyCollection,
Node,
Tag,
consumeTag,
dirtyTag,
createTag
createTag,
dirtyCollection,
dirtyTag
} from './tracking'

export const REDUX_PROXY_LABEL = Symbol()
Expand Down
6 changes: 3 additions & 3 deletions src/autotrackMemoize/tracking.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Cell } from './autotracking'
import {
createCell as createStorage,
getValue as consumeTag,
setValue,
Cell
createCell as createStorage,
setValue
} from './autotracking'

export type Tag = Cell<unknown>
Expand Down
Loading

0 comments on commit a87ac69

Please sign in to comment.