Skip to content
Source
Sign inSign up
TanStack/store
Open History to see the last commit

ReadonlyAtom.md

58 lines944 Bytes

1---
2id: ReadonlyAtom
3title: ReadonlyAtom
4---
5​
6Defined in: [types.ts:67](https://github.com/TanStack/store/blob/main/packages/store/src/types.ts#L67)
7​
8An atom that is read-only and cannot be set.
9​
10## Example
11​
12```ts
13const atom = createAtom(() => 42);
14// @ts-expect-error - Cannot set a readonly atom
15atom.set(43);
16```
17​
18## Extends
19​
20- [`BaseAtom`](BaseAtom.md)\<`T`\>
21​
22## Type Parameters
23​
24### T
25​
26`T`
27​
28## Properties
29​
30### get
31​
32```ts
33get: () => T;
34```
35​
36Defined in: [types.ts:30](https://github.com/TanStack/store/blob/main/packages/store/src/types.ts#L30)
37​
38#### Returns
39​
40`T`
41​
42#### Inherited from
43​
44[`BaseAtom`](BaseAtom.md).[`get`](BaseAtom.md#get)
45​
46***
47​
48### subscribe
49​
50```ts
51subscribe: (observer) => Subscription & (next, error?, complete?) => Subscription;
52```
53​
54Defined in: [types.ts:21](https://github.com/TanStack/store/blob/main/packages/store/src/types.ts#L21)
55​
56#### Inherited from
57​
58[`BaseAtom`](BaseAtom.md).[`subscribe`](BaseAtom.md#subscribe)