@dxos/echo-react 0.9.1-main.c7dcc2e112 → 0.10.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/dist/lib/neutral/index.mjs.map +2 -2
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/useObject.d.ts +12 -1
- package/dist/types/src/useObject.d.ts.map +1 -1
- package/dist/types/src/useType.d.ts +1 -1
- package/dist/types/src/useType.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/useObject.ts +12 -1
- package/src/useType.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "React integration for ECHO.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@effect-atom/atom": "^0.5.3",
|
|
29
29
|
"@effect-atom/atom-react": "^0.5.0",
|
|
30
|
-
"@dxos/echo": "0.
|
|
30
|
+
"@dxos/echo": "0.10.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@testing-library/react": "^16.3.
|
|
34
|
-
"@types/react": "~19.2.
|
|
33
|
+
"@testing-library/react": "^16.3.2",
|
|
34
|
+
"@types/react": "~19.2.17",
|
|
35
35
|
"@types/react-dom": "~19.2.3",
|
|
36
|
-
"react": "~19.2.
|
|
37
|
-
"react-dom": "~19.2.
|
|
38
|
-
"@dxos/echo-client": "0.
|
|
36
|
+
"react": "~19.2.7",
|
|
37
|
+
"react-dom": "~19.2.7",
|
|
38
|
+
"@dxos/echo-client": "0.10.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"react": "~19.2.
|
|
41
|
+
"react": "~19.2.7"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
package/src/useObject.ts
CHANGED
|
@@ -24,9 +24,16 @@ export const useObject: {
|
|
|
24
24
|
* Hook to subscribe to a Ref's target object.
|
|
25
25
|
* Automatically dereferences the ref and handles async loading.
|
|
26
26
|
* Returns a snapshot (undefined if the ref hasn't loaded yet).
|
|
27
|
+
* Re-renders the component when the ref resolves or the target object changes.
|
|
27
28
|
*
|
|
28
29
|
* @param ref - The Ref to dereference and subscribe to
|
|
29
30
|
* @returns The current target snapshot (or undefined if not loaded) and update callback
|
|
31
|
+
*
|
|
32
|
+
* @idiom org.dxos.echo-react.useObjectReactive
|
|
33
|
+
* applies: Reading a ref's target (or a specific property) inside a React component — establishes a reactive subscription so the component re-renders when the ref resolves or the value changes
|
|
34
|
+
* instead-of: `ref.target` — synchronous and not reactive; returns `undefined` when the target isn't loaded yet and never triggers a re-render when it becomes available
|
|
35
|
+
* uses: {@link useObject}
|
|
36
|
+
* related: org.dxos.echo.objAtomReactive, org.dxos.echo.refLoad
|
|
30
37
|
*/
|
|
31
38
|
<T extends Obj.Unknown>(ref: Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
32
39
|
|
|
@@ -65,7 +72,7 @@ export const useObject: {
|
|
|
65
72
|
* @param objOrRef - The Echo object or Ref to subscribe to
|
|
66
73
|
* @returns The current object snapshot (or undefined) and update callback
|
|
67
74
|
*/
|
|
68
|
-
<T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
75
|
+
<T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
78
|
* Hook to subscribe to a specific property of an Echo object.
|
|
@@ -208,6 +215,10 @@ const useObjectProperty = <T extends Obj.Unknown, K extends keyof T>(
|
|
|
208
215
|
* This hook is useful for aggregate computations like counts or filtering
|
|
209
216
|
* across multiple refs without using .target directly.
|
|
210
217
|
*
|
|
218
|
+
* @deprecated Subscribes the component to the whole list, re-rendering on any element's change. Prefer pushing
|
|
219
|
+
* the subscription down — derive the aggregate in an atom (reading each `Obj.atom(ref)`) and read it where it is
|
|
220
|
+
* needed, or subscribe to the individual ref/property closest to the consumer — to keep subscriptions granular.
|
|
221
|
+
*
|
|
211
222
|
* @param refs - Array of Refs to dereference and subscribe to
|
|
212
223
|
* @returns Array of loaded target snapshots (excludes unloaded refs)
|
|
213
224
|
*/
|
package/src/useType.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useMemo, useSyncExternalStore } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Database, DXN, EID, Filter, Query, Scope, Type, URI } from '@dxos/echo';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Subscribe to and retrieve a type by its URI from a space: a static schema's typename DXN, or a
|