Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

automerge-repo-solid-primitives

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

automerge-repo-solid-primitives

automerge-repo primitives for your solidjs app

  • 1.1.0
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-77.78%
Maintainers
1
Weekly downloads
 
Created
Source

Solid Primitives for Automerge Repo

Helpers for using <img alt="" src=.assets/automerge.png width=22 height=22> Automerge with <img alt="" src=.assets/solid.png width=22 height=22> SolidJS .

RepoContext

A convenience context for Automerge-Repo Solid apps. Optional: if you prefer you can pass a repo as an option to useHandle or useDocument.

<RepoContext.Provider repo={Repo}>
	<App />
</RepoContext.Provider>

useRepo

Get the repo from the context.

useRepo(): Repo

e.g.

let repo = useRepo()

useHandle

Get a handle from the repo as a resource.

useHandle<T>(
    () => AnyDocumentId,
    options?: {repo: Repo}
): Resource<Handle<T>>

e.g.

let handle = useHandle(id)
// or
let handle = useHandle(id, {repo})

The repo option can be left out if you are using RepoContext.

useDocument

Get a document and change function from the repo as a resource.

useDocument<T>(
    () => AnyDocumentId,
    options?: {repo: Repo}
): [Resource<T>, (fn: changeFn<T>) => void]

e.g.

let [doc, change] = useDocument(id)
// or
let [doc, change] = useDocument(id, {repo})

The repo option can be left out if you are using RepoContext.

createDocumentStore

Create a store for a handle's document. It's subscribed to the handle's changes, and converts incoming automerge operations to store updates, providing fine-grained reactivity that's consistent across space and time.

createDocumentStore<T>(
    () => Handle<T>
): Resource<Doc<T>>

e.g.

let handle = useHandle(id, {repo})
let doc = createDocumentStore(handle)

return <h1>{doc.items[1].title}</h1>

Keywords

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc