|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1007 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | import type { Cell } from './autotracking'
|
|---|
| 2 | import {
|
|---|
| 3 | getValue as consumeTag,
|
|---|
| 4 | createCell as createStorage,
|
|---|
| 5 | setValue
|
|---|
| 6 | } from './autotracking'
|
|---|
| 7 |
|
|---|
| 8 | export type Tag = Cell<unknown>
|
|---|
| 9 |
|
|---|
| 10 | const neverEq = (a: any, b: any): boolean => false
|
|---|
| 11 |
|
|---|
| 12 | export function createTag(): Tag {
|
|---|
| 13 | return createStorage(null, neverEq)
|
|---|
| 14 | }
|
|---|
| 15 | export { consumeTag }
|
|---|
| 16 | export function dirtyTag(tag: Tag, value: any): void {
|
|---|
| 17 | setValue(tag, value)
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | export 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 |
|
|---|
| 34 | export 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 |
|
|---|
| 44 | export 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.