atom.io 0.36.1 → 0.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/internal/index.d.ts +15 -11
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +149 -164
- package/dist/internal/index.js.map +1 -1
- package/dist/main/index.d.ts +2 -8
- package/dist/main/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/internal/caching.ts +23 -26
- package/src/internal/get-state/read-or-compute-value.ts +4 -8
- package/src/internal/join/create-join.ts +3 -2
- package/src/internal/selector/create-readonly-held-selector.ts +1 -1
- package/src/internal/selector/create-readonly-pure-selector.ts +1 -1
- package/src/internal/selector/create-writable-held-selector.ts +2 -3
- package/src/internal/selector/create-writable-pure-selector.ts +2 -2
- package/src/internal/set-state/evict-downstream.ts +17 -15
- package/src/internal/set-state/index.ts +1 -0
- package/src/internal/set-state/reset-in-store.ts +6 -50
- package/src/internal/set-state/set-atom.ts +4 -4
- package/src/internal/set-state/set-into-store.ts +24 -9
- package/src/internal/subscribe/subscribe-in-store.ts +7 -7
- package/src/internal/subscribe/subscribe-to-timeline.ts +2 -2
- package/src/main/tokens.ts +3 -8
|
@@ -6,19 +6,21 @@ import { getFamilyOfToken } from "../families/get-family-of-token"
|
|
|
6
6
|
import { closeOperation, openOperation } from "../operation"
|
|
7
7
|
import type { Store } from "../store"
|
|
8
8
|
import { withdraw } from "../store"
|
|
9
|
+
import { resetAtomOrSelector } from "./reset-atom-or-selector"
|
|
10
|
+
import { RESET_STATE } from "./reset-in-store"
|
|
9
11
|
import { setAtomOrSelector } from "./set-atom-or-selector"
|
|
10
12
|
|
|
11
13
|
export function setIntoStore<T, New extends T>(
|
|
12
14
|
store: Store,
|
|
13
15
|
token: WritableToken<T>,
|
|
14
|
-
value: New | ((oldValue: T) => New),
|
|
16
|
+
value: New | typeof RESET_STATE | ((oldValue: T) => New),
|
|
15
17
|
): void
|
|
16
18
|
|
|
17
19
|
export function setIntoStore<T, K extends Canonical, New extends T>(
|
|
18
20
|
store: Store,
|
|
19
21
|
token: WritableFamilyToken<T, K>,
|
|
20
22
|
key: K,
|
|
21
|
-
value: New | ((oldValue: T) => New),
|
|
23
|
+
value: New | typeof RESET_STATE | ((oldValue: T) => New),
|
|
22
24
|
): void
|
|
23
25
|
|
|
24
26
|
export function setIntoStore<T, New extends T>(
|
|
@@ -27,14 +29,17 @@ export function setIntoStore<T, New extends T>(
|
|
|
27
29
|
| [
|
|
28
30
|
token: WritableFamilyToken<T, Canonical>,
|
|
29
31
|
key: Canonical,
|
|
30
|
-
value: New | ((oldValue: T) => New),
|
|
32
|
+
value: New | typeof RESET_STATE | ((oldValue: T) => New),
|
|
33
|
+
]
|
|
34
|
+
| [
|
|
35
|
+
token: WritableToken<T>,
|
|
36
|
+
value: New | typeof RESET_STATE | ((oldValue: T) => New),
|
|
31
37
|
]
|
|
32
|
-
| [token: WritableToken<T>, value: New | ((oldValue: T) => New)]
|
|
33
38
|
): void {
|
|
34
39
|
let token: WritableToken<T>
|
|
35
40
|
let family: WritableFamilyToken<T, Canonical> | null
|
|
36
41
|
let key: Canonical | null
|
|
37
|
-
let value: New | ((oldValue: T) => New)
|
|
42
|
+
let value: New | typeof RESET_STATE | ((oldValue: T) => New)
|
|
38
43
|
if (params.length === 2) {
|
|
39
44
|
token = params[0]
|
|
40
45
|
value = params[1]
|
|
@@ -51,6 +56,8 @@ export function setIntoStore<T, New extends T>(
|
|
|
51
56
|
token = findInStore(store, family, key)
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
const action = value === RESET_STATE ? `reset` : `set`
|
|
60
|
+
|
|
54
61
|
if (`counterfeit` in token && `family` in token) {
|
|
55
62
|
const subKey = token.family.subKey
|
|
56
63
|
const disposal = store.disposalTraces.buffer.find(
|
|
@@ -60,7 +67,9 @@ export function setIntoStore<T, New extends T>(
|
|
|
60
67
|
`❌`,
|
|
61
68
|
token.type,
|
|
62
69
|
token.key,
|
|
63
|
-
`could not be
|
|
70
|
+
`could not be`,
|
|
71
|
+
action,
|
|
72
|
+
`because it was not found in the store "${store.config.name}".`,
|
|
64
73
|
disposal
|
|
65
74
|
? `This state was previously disposed:\n${disposal.trace}`
|
|
66
75
|
: `No previous disposal trace was found.`,
|
|
@@ -71,14 +80,16 @@ export function setIntoStore<T, New extends T>(
|
|
|
71
80
|
const rejectionTime = openOperation(store, token)
|
|
72
81
|
if (rejectionTime) {
|
|
73
82
|
const unsubscribe = store.on.operationClose.subscribe(
|
|
74
|
-
`waiting to
|
|
83
|
+
`waiting to ${action} "${token.key}" at T-${rejectionTime}`,
|
|
75
84
|
function waitUntilOperationCloseToSetState() {
|
|
76
85
|
unsubscribe()
|
|
77
86
|
store.logger.info(
|
|
78
87
|
`🟢`,
|
|
79
88
|
token.type,
|
|
80
89
|
token.key,
|
|
81
|
-
`resuming deferred
|
|
90
|
+
`resuming deferred`,
|
|
91
|
+
action,
|
|
92
|
+
`from T-${rejectionTime}`,
|
|
82
93
|
)
|
|
83
94
|
setIntoStore(store, token, value)
|
|
84
95
|
},
|
|
@@ -86,6 +97,10 @@ export function setIntoStore<T, New extends T>(
|
|
|
86
97
|
return
|
|
87
98
|
}
|
|
88
99
|
const state = withdraw(store, token)
|
|
89
|
-
|
|
100
|
+
if (value === RESET_STATE) {
|
|
101
|
+
resetAtomOrSelector(store, state)
|
|
102
|
+
} else {
|
|
103
|
+
setAtomOrSelector(store, state, value)
|
|
104
|
+
}
|
|
90
105
|
closeOperation(store)
|
|
91
106
|
}
|
|
@@ -7,13 +7,13 @@ import type {
|
|
|
7
7
|
TransactionUpdateHandler,
|
|
8
8
|
UpdateHandler,
|
|
9
9
|
} from "atom.io"
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "
|
|
10
|
+
|
|
11
|
+
import { arbitrary } from "../arbitrary"
|
|
12
|
+
import type { Store } from "../store"
|
|
13
|
+
import type { Fn } from "../utility-types"
|
|
14
|
+
import { subscribeToState } from "./subscribe-to-state"
|
|
15
|
+
import { subscribeToTimeline } from "./subscribe-to-timeline"
|
|
16
|
+
import { subscribeToTransaction } from "./subscribe-to-transaction"
|
|
17
17
|
|
|
18
18
|
export function subscribeInStore<T>(
|
|
19
19
|
store: Store,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TimelineManageable, TimelineToken, TimelineUpdate } from "atom.io"
|
|
2
2
|
|
|
3
|
-
import type { Store } from "
|
|
4
|
-
import { withdraw } from "
|
|
3
|
+
import type { Store } from "../store/store"
|
|
4
|
+
import { withdraw } from "../store/withdraw"
|
|
5
5
|
|
|
6
6
|
export const subscribeToTimeline = <ManagedAtom extends TimelineManageable>(
|
|
7
7
|
store: Store,
|
package/src/main/tokens.ts
CHANGED
|
@@ -18,27 +18,22 @@ export type AtomIOToken =
|
|
|
18
18
|
| TimelineToken<any>
|
|
19
19
|
| TransactionToken<any>
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* These states cannot be set.
|
|
23
|
-
*/
|
|
24
21
|
export type ReadableToken<T, K extends Canonical = any> =
|
|
25
22
|
| AtomToken<T, K>
|
|
26
23
|
| SelectorToken<T, K>
|
|
27
|
-
|
|
28
|
-
* These states can be set.
|
|
29
|
-
*/
|
|
24
|
+
|
|
30
25
|
export type WritableToken<T, K extends Canonical = any> =
|
|
31
26
|
| AtomToken<T, K>
|
|
32
27
|
| WritableSelectorToken<T, K>
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
|
-
* States belonging to this family can be
|
|
30
|
+
* States belonging to this family can be read from the store.
|
|
36
31
|
*/
|
|
37
32
|
export type ReadableFamilyToken<T, K extends Canonical> =
|
|
38
33
|
| AtomFamilyToken<T, K>
|
|
39
34
|
| SelectorFamilyToken<T, K>
|
|
40
35
|
/**
|
|
41
|
-
* States belonging to this family can be
|
|
36
|
+
* States belonging to this family can be written directly.
|
|
42
37
|
*/
|
|
43
38
|
export type WritableFamilyToken<T, K extends Canonical> =
|
|
44
39
|
| AtomFamilyToken<T, K>
|