Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out write hooks API #20

Open
15 tasks
achou11 opened this issue Dec 19, 2024 · 0 comments
Open
15 tasks

Figure out write hooks API #20

achou11 opened this issue Dec 19, 2024 · 0 comments
Assignees

Comments

@achou11
Copy link
Member

achou11 commented Dec 19, 2024

We have "read hooks" which are meant for retrieving data via the core api. Now we need "write hooks" in order to create and update data via the core api.

Non-exhaustive list of functionality that's needed:

  • set device info
  • accept an invite
  • reject an invite
  • request invite cancellation
  • send an invite
  • add a server peer
  • create a blob (might not actually expose this one since this would mostly be used internally by something like creating/updating a document)
  • set device as archive device
  • create a document
  • update a document
  • delete a document
  • create a project
  • leave a project
  • update project settings
  • import a project configuration

Another notable thing that was discussed is to to have the document create+update handle creating blobs + attachments internally i.e. something like:

function App() {
  const createDoc = useCreateDocument()

  function onPress() {
    createDoc.mutate({ value: ..., attachmentsToAdd: Array<...> })
  }
}

If we want to "remove" attachments with this approach, the intention is to omit the attachment references in the value that's specified above.


For a potential return value for most of the hooks, we discussed something along the lines of:

type WriteHookResult = {
  mutate: (vars: ..., opts: ...) => void
  reset: () => void
  status: string
}

Most of the above would be derived from what React Query provides, although I can some changes:

  • rename the mutate field (more cosmetic than anything else)

Questions:

  • are there any other notable core-related functionality that we need to expose as a write hook?
  • does the WriteHookResult look sufficient for our needs?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant