MCPcopy
hub / github.com/nanostores/nanostores / ReadableAtom

Interface ReadableAtom

atom/index.d.ts:18–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 * Store object.
17 */
18export interface ReadableAtom<Value = any> {
19 /**
20 * Get store value.
21 *
22 * In contrast with {@link ReadableAtom#value} this value will be always
23 * initialized even if store had no listeners.
24 *
25 * ```js
26 * $store.get()
27 * ```
28 *
29 * @returns Store value.
30 */
31 get(): Value
32
33 /**
34 * Low-level attribute to read store’s initial value.
35 */
36 readonly init: undefined | Value
37
38 /**
39 * Listeners count.
40 */
41 readonly lc: number
42
43 /**
44 * Subscribe to store changes.
45 *
46 * In contrast with {@link Store#subscribe} it do not call listener
47 * immediately.
48 *
49 * @param listener Callback with store value and old value.
50 * @returns Function to remove listener.
51 */
52 listen(
53 listener: (
54 value: ReadonlyIfObject<Value>,
55 oldValue: ReadonlyIfObject<Value>
56 ) => void
57 ): () => void
58
59 /**
60 * Low-level method to notify listeners about changes in the store.
61 *
62 * Can cause unexpected behaviour when combined with frontend frameworks
63 * that perform equality checks for values, such as React.
64 */
65 notify(oldValue?: ReadonlyIfObject<Value>): void
66
67 /**
68 * Unbind all listeners.
69 */
70 off(): void
71
72 /**
73 * Subscribe to store changes and call listener immediately.
74 *
75 * ```

Callers 18

index.test.tsFile · 0.80
index.test.tsFile · 0.80
types.tsFile · 0.80
index.test.tsFile · 0.80
getKeyFunction · 0.80
index.test.tsFile · 0.80
setFunction · 0.80
errors.tsFile · 0.80
index.test.tsFile · 0.65
getFunction · 0.65
subscribeFunction · 0.65
errors.tsFile · 0.65

Calls

no outgoing calls

Tested by

no test coverage detected