| 16 | * Store object. |
| 17 | */ |
| 18 | export 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 | * ``` |
no outgoing calls
no test coverage detected