11# SolidJS primitives for Automerge Repo
22
3- helpers for using <a href =" https://automerge.org/docs/repositories/ " >
3+ Helpers for using <a href =" https://automerge.org/docs/repositories/ " >
44<img alt="" src=.assets/automerge.png width=22 height=22>
55Automerge
66</a > with <a href =" https://www.solidjs.com/ " >
@@ -11,24 +11,25 @@ SolidJS
1111> [ !note]
1212>
1313> This library targets ` @automerge/automerge-repo@2 ` which is currently in
14- > Alpha.
14+ > Alpha
1515>
1616> Changes adapting to breaking changes will be reflected as patch bumps in this
1717> library, until ` @automerge/automerge-repo@2 ` is stable.
1818
1919``` sh
20+ pnpm add @automerge/automerge-repo@next
2021pnpm add automerge-repo-solid-primitives@next
2122```
2223
2324## useDocument ✨
2425
25- get a fine-grained live view of an automerge document from its URL.
26+ Get a fine-grained live view of an automerge document from its URL.
2627
27- when the handle receives changes, it converts the incoming automerge patch ops
28+ When the handle receives changes, it converts the incoming automerge patch ops
2829to precise solid store updates, giving you fine-grained reactivity that's
2930consistent across space and time.
3031
31- returns ` [doc, handle] ` .
32+ Returns ` [doc, handle] ` .
3233
3334``` ts
3435useDocument <T >(
@@ -46,55 +47,55 @@ const inc = () => handle()?.change(d => d.count++)
4647return <button onclick = { inc } >{ doc ()?.count } </button >
4748```
4849
49- the ` {repo} ` option can be left out if you are using [ RepoContext] ( #repocontext ) .
50+ The ` {repo} ` option can be left out if you are using [ RepoContext] ( #repocontext ) .
5051
5152## createDocumentProjection
5253
53- get a fine-grained live view from a signal automerge handle.
54+ Get a fine-grained live view from a signal automerge handle.
5455
55- underlying primitive for [ ` useDocument ` ] ( #usedocument- ) .
56+ Underlying primitive for [ ` useDocument ` ] ( #usedocument- ) .
5657
57- works with [ ` useHandle ` ] ( #usehandle ) .
58+ Works with [ ` useHandle ` ] ( #usehandle ) .
5859
5960``` ts
6061createDocumentProjection <T >(() => AutomergeUrl ): Doc < T >
6162```
6263
6364``` tsx
6465// example
65- let handle = repo .find (url )
66- let doc = makeDeepDocumentProjection <{items: {title: string }[]}>(handle )
66+ const handle = repo .find (url )
67+ const doc = makeDocumentProjection <{items: {title: string }[]}>(handle )
6768
6869// subscribes fine-grained to doc.items[1].title
6970return <h1 >{ doc .items [1 ].title } </h1 >
7071```
7172
7273## makeDocumentProjection
7374
74- just like ` useDocument ` , but without a reactive input.
75+ Just like ` createDocumentProjection ` , but without a reactive input.
7576
76- underlying primitive for [ ` createDocumentProjection ` ] ( #createdocumentprojection ) .
77+ Underlying primitive for [ ` createDocumentProjection ` ] ( #createDocumentProjection ) .
7778
7879``` ts
79- makeDeepDocumentProjection <T >(handle : Handle < T > ): Doc < T >
80+ makeDocumentProjection <T >(handle : Handle < T > ): Doc < T >
8081```
8182
8283``` tsx
8384// example
84- let handle = repo .find (url )
85- let doc = makeDeepDocumentProjection <{items: {title: string }[]}>(handle )
85+ const handle = repo .find (url )
86+ const doc = makeDocumentProjection <{items: {title: string }[]}>(handle )
8687
8788// subscribes fine-grained to doc.items[1].title
8889return <h1 >{ doc .items [1 ].title } </h1 >
8990```
9091
9192## useHandle
9293
93- get a [ handle] ( https://automerge.org/docs/repositories/dochandles/ ) from the
94+ Get a [ handle] ( https://automerge.org/docs/repositories/dochandles/ ) from the
9495repo as a
9596[ resource] ( https://docs.solidjs.com/reference/basic-reactivity/create-resource ) .
9697
97- perfect for handing to ` createDocumentProjection ` .
98+ Perfect for handing to ` createDocumentProjection ` .
9899
99100``` ts
100101useHandle <T >(
@@ -109,7 +110,7 @@ const handle = useHandle(id, {repo})
109110const handle = useHandle (id )
110111```
111112
112- the ` repo ` option can be left out if you are using [ RepoContext] ( #repocontext ) .
113+ The ` repo ` option can be left out if you are using [ RepoContext] ( #repocontext ) .
113114
114115## context
115116
0 commit comments