In front-end apps, often the need for a UUID comes up to be able to uniquely identify values in the absence of a backend DB ID.
Since Arbor already assigns a unique Seed value to nodes so it can track them across mutations (even when using ImmutableArbor that applies structural sharing to the underlying data), the idea is to expose that value so users can use it to uniquely identify values in their application state without the need to create UUIDs.
Example:
import { id } from "@arborjs/store"
const store = new Arbor([
{ text: "todo 1" },
{ text: "todo 2" },
])
const arrayId = id(store.state)
=> 0
const todo1Id = id(store.state[0])
=> 1
const todo2Id = id(store.state[1])
=> 2
This can be handy in React apps to use as keys to components.
In front-end apps, often the need for a UUID comes up to be able to uniquely identify values in the absence of a backend DB ID.
Since Arbor already assigns a unique
Seedvalue to nodes so it can track them across mutations (even when usingImmutableArborthat applies structural sharing to the underlying data), the idea is to expose that value so users can use it to uniquely identify values in their application state without the need to create UUIDs.Example:
This can be handy in React apps to use as keys to components.