2023-06-20 13:31:26 +00:00
## API Report File for "@tldraw/state"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { FunctionComponent } from 'react';
import { default as React_2 } from 'react';
// @public
export interface Atom< Value , Diff = unknown > extends Signal< Value , Diff > {
set(value: Value, diff?: Diff): Value;
update(updater: (value: Value) => Value): Value;
}
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
atom: typeof atom_2;
2023-06-20 13:31:26 +00:00
// @public
export interface AtomOptions< Value , Diff > {
computeDiff?: ComputeDiff< Value , Diff > ;
historyLength?: number;
isEqual?: (a: any, b: any) => boolean;
}
// @public
export interface Computed< Value , Diff = unknown > extends Signal< Value , Diff > {
readonly isActivelyListening: boolean;
// @internal (undocumented)
readonly parentEpochs: number[];
// @internal (undocumented)
readonly parents: Signal< any , any > [];
}
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
computed: typeof computed_2;
2023-06-20 13:31:26 +00:00
// @public
export interface ComputedOptions< Value , Diff > {
computeDiff?: ComputeDiff< Value , Diff > ;
historyLength?: number;
isEqual?: (a: any, b: any) => boolean;
}
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
EffectScheduler: typeof EffectScheduler_2;
2023-06-20 13:31:26 +00:00
// @public (undocumented)
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
EMPTY_ARRAY: [];
2023-06-20 13:31:26 +00:00
// @public
export function getComputedInstance< Obj extends object , Prop extends keyof Obj > (obj: Obj, propertyName: Prop): Computed< Obj [ Prop ] > ;
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
isAtom: typeof isAtom_2;
2023-06-20 13:31:26 +00:00
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
isSignal: typeof isSignal_2;
2023-06-20 13:31:26 +00:00
// @public
export const isUninitialized: (value: any) => value is typeof UNINITIALIZED;
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
react: typeof react_2;
2023-06-20 13:31:26 +00:00
// @public
export interface Reactor< T = unknown > {
2023-12-14 13:35:34 +00:00
scheduler: EffectScheduler_2< T > ;
2023-06-20 13:31:26 +00:00
start(options?: {
force?: boolean;
}): void;
stop(): void;
}
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
reactor: typeof reactor_2;
2023-06-20 13:31:26 +00:00
// @public (undocumented)
export const RESET_VALUE: unique symbol;
// @public (undocumented)
export type RESET_VALUE = typeof RESET_VALUE;
// @public
export interface Signal< Value , Diff = unknown > {
__unsafe__getWithoutCapture(): Value;
// @internal (undocumented)
children: ArraySet< Child > ;
2023-11-13 11:51:22 +00:00
get(): Value;
2023-06-20 13:31:26 +00:00
getDiffSince(epoch: number): Diff[] | RESET_VALUE;
lastChangedEpoch: number;
name: string;
2023-11-13 11:51:22 +00:00
// @deprecated (undocumented)
value: Value;
2023-06-20 13:31:26 +00:00
}
// @public
export function track< T extends FunctionComponent < any > >(baseComponent: T): T extends React_2.MemoExoticComponent< any > ? T : React_2.MemoExoticComponent< T > ;
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
transact: typeof transact_2;
2023-06-20 13:31:26 +00:00
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
transaction: typeof transaction_2;
2023-06-20 13:31:26 +00:00
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
unsafe__withoutCapture: typeof unsafe__withoutCapture_2;
2023-06-20 13:31:26 +00:00
// @public
export function useAtom< Value , Diff = unknown > (
name: string,
valueOrInitialiser: (() => Value) | Value,
options?: AtomOptions< Value , Diff > ): Atom< Value , Diff > ;
// @public
export function useComputed< Value > (name: string, compute: () => Value, deps: any[]): Computed< Value > ;
// @public (undocumented)
export function useComputed< Value , Diff = unknown > (name: string, compute: () => Value, opts: ComputedOptions< Value , Diff > , deps: any[]): Computed< Value > ;
// @public (undocumented)
export function useQuickReactor(name: string, reactFn: () => void, deps?: any[]): void;
// @public (undocumented)
export function useReactor(name: string, reactFn: () => void, deps?: any[] | undefined): void;
// @internal (undocumented)
export function useStateTracking< T > (name: string, render: () => T): T;
// @public
export function useValue< Value > (value: Signal< Value > ): Value;
// @public (undocumented)
export function useValue< Value > (name: string, fn: () => Value, deps: unknown[]): Value;
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
whyAmIRunning: typeof whyAmIRunning_2;
2023-06-20 13:31:26 +00:00
// @public
2023-12-14 13:35:34 +00:00
export const
/**
* Creates a new [[Atom]].
*
* An Atom is a signal that can be updated directly by calling [[Atom.set]] or [[Atom.update]].
*
* @example
* ```ts
* const name = atom('name', 'John')
*
* name.get() // 'John'
*
* name.set('Jane')
*
* name.get() // 'Jane'
* ```
*
* @public
*/
withDiff: typeof withDiff_2;
2023-06-20 13:31:26 +00:00
// (No @packageDocumentation comment for this package)
```