source: node_modules/reselect/src/autotrackMemoize/tracking.ts

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1007 bytes
RevLine 
[d24f17c]1import type { Cell } from './autotracking'
2import {
3 getValue as consumeTag,
4 createCell as createStorage,
5 setValue
6} from './autotracking'
7
8export type Tag = Cell<unknown>
9
10const neverEq = (a: any, b: any): boolean => false
11
12export function createTag(): Tag {
13 return createStorage(null, neverEq)
14}
15export { consumeTag }
16export function dirtyTag(tag: Tag, value: any): void {
17 setValue(tag, value)
18}
19
20export interface Node<
21 T extends Array<unknown> | Record<string, unknown> =
22 | Array<unknown>
23 | Record<string, unknown>
24> {
25 collectionTag: Tag | null
26 tag: Tag | null
27 tags: Record<string, Tag>
28 children: Record<string, Node>
29 proxy: T
30 value: T
31 id: number
32}
33
34export const consumeCollection = (node: Node): void => {
35 let tag = node.collectionTag
36
37 if (tag === null) {
38 tag = node.collectionTag = createTag()
39 }
40
41 consumeTag(tag)
42}
43
44export const dirtyCollection = (node: Node): void => {
45 const tag = node.collectionTag
46
47 if (tag !== null) {
48 dirtyTag(tag, null)
49 }
50}
Note: See TracBrowser for help on using the repository browser.