atom.io 0.4.1 → 0.5.0
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/README.md +38 -10
- package/dist/index.d.mts +598 -0
- package/dist/index.d.ts +51 -14
- package/dist/index.js +143 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -28
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +18 -0
- package/json/dist/index.d.ts +18 -0
- package/json/dist/index.js +51 -0
- package/json/dist/index.js.map +1 -0
- package/json/dist/index.mjs +15 -0
- package/json/dist/index.mjs.map +1 -0
- package/json/package.json +15 -0
- package/package.json +34 -7
- package/react/dist/index.d.mts +17 -0
- package/react-devtools/dist/index.d.mts +15 -0
- package/react-devtools/dist/index.js +1 -1
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +1 -1
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +25 -0
- package/realtime/dist/index.d.ts +25 -0
- package/realtime/dist/index.js +168 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/dist/index.mjs +130 -0
- package/realtime/dist/index.mjs.map +1 -0
- package/realtime/package.json +15 -0
- package/src/index.ts +22 -0
- package/src/internal/atom-internal.ts +1 -1
- package/src/internal/families-internal.ts +3 -3
- package/src/internal/get.ts +22 -12
- package/src/internal/selector-internal.ts +10 -0
- package/src/internal/set.ts +1 -1
- package/src/internal/store.ts +1 -1
- package/src/internal/subscribe-internal.ts +5 -0
- package/src/internal/timeline-internal.ts +13 -1
- package/src/internal/transaction-internal.ts +24 -9
- package/src/json/index.ts +1 -0
- package/src/json/select-json.ts +18 -0
- package/src/react-explorer/explorer-states.ts +5 -5
- package/src/react-explorer/index.ts +1 -1
- package/src/react-explorer/space-states.ts +6 -7
- package/src/realtime/hook-composition/expose-family.ts +101 -0
- package/src/realtime/hook-composition/expose-single.ts +38 -0
- package/src/realtime/hook-composition/index.ts +11 -0
- package/src/realtime/hook-composition/receive-transaction.ts +19 -0
- package/src/realtime/index.ts +1 -0
- package/src/realtime-client/hook-composition/compose-realtime-hooks.ts +62 -0
- package/src/realtime-client/hook-composition/realtime-client-family-member.ts +28 -0
- package/src/realtime-client/hook-composition/realtime-client-family.ts +26 -0
- package/src/realtime-client/hook-composition/realtime-client-single.ts +24 -0
- package/src/realtime-client/hook-composition/realtime-client-transaction.ts +35 -0
- package/src/realtime-client/index.ts +1 -0
- package/src/selector.ts +9 -6
- package/src/silo.ts +45 -0
- package/src/subscribe.ts +13 -1
- package/src/transaction.ts +11 -4
package/src/subscribe.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ƒn } from "~/packages/anvl/src/function"
|
|
2
|
+
|
|
3
|
+
import type { ReadonlySelectorToken, StateToken, TransactionToken } from "."
|
|
2
4
|
import type { Store, TransactionUpdate } from "./internal"
|
|
3
5
|
import { IMPLICIT, subscribeToRootAtoms, withdraw } from "./internal"
|
|
4
6
|
|
|
@@ -11,6 +13,11 @@ export const subscribe = <T>(
|
|
|
11
13
|
store: Store = IMPLICIT.STORE
|
|
12
14
|
): (() => void) => {
|
|
13
15
|
const state = withdraw<T>(token, store)
|
|
16
|
+
if (state === null) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
19
|
+
)
|
|
20
|
+
}
|
|
14
21
|
const subscription = state.subject.subscribe(handleUpdate)
|
|
15
22
|
store.config.logger?.info(`👀 subscribe to "${state.key}"`)
|
|
16
23
|
const dependencySubscriptions =
|
|
@@ -45,6 +52,11 @@ export const subscribeToTransaction = <ƒ extends ƒn>(
|
|
|
45
52
|
store = IMPLICIT.STORE
|
|
46
53
|
): (() => void) => {
|
|
47
54
|
const tx = withdraw(token, store)
|
|
55
|
+
if (tx === null) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
48
60
|
store.config.logger?.info(`👀 subscribe to transaction "${token.key}"`)
|
|
49
61
|
const subscription = tx.subject.subscribe(handleUpdate)
|
|
50
62
|
const unsubscribe = () => {
|
package/src/transaction.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type * as Rx from "rxjs"
|
|
2
2
|
|
|
3
|
+
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
|
+
|
|
3
5
|
import type { ReadonlySelectorToken, StateToken, TransactionToken } from "."
|
|
4
6
|
import type { Store, TransactionUpdate } from "./internal"
|
|
5
7
|
import { IMPLICIT, transaction__INTERNAL, withdraw } from "./internal"
|
|
6
8
|
|
|
7
|
-
export type ƒn = (...parameters: any[]) => any
|
|
8
|
-
|
|
9
9
|
export type Transactors = {
|
|
10
10
|
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S
|
|
11
11
|
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void
|
|
@@ -44,5 +44,12 @@ export function transaction<ƒ extends ƒn>(
|
|
|
44
44
|
|
|
45
45
|
export const runTransaction =
|
|
46
46
|
<ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>
|
|
47
|
-
(...parameters: Parameters<ƒ>): ReturnType<ƒ> =>
|
|
48
|
-
withdraw(token, store)
|
|
47
|
+
(...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
|
|
48
|
+
const tx = withdraw(token, store)
|
|
49
|
+
if (tx) {
|
|
50
|
+
return tx.run(...parameters)
|
|
51
|
+
}
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
54
|
+
)
|
|
55
|
+
}
|