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

add indexdb integration to yjs hooks #3

Closed

Conversation

rolyatmax
Copy link
Member

@rolyatmax rolyatmax commented Jul 25, 2023

First 3 commits contain some small refactoring. A description for each change is in the commit messages.

Adding IndexDBProvider is still WIP

@rolyatmax rolyatmax self-assigned this Jul 25, 2023
@linear
Copy link

linear bot commented Jul 25, 2023

DIS-1140 Add IndexDB integration to yjs hooks

https://github.com/yjs/y-indexeddb

This will allow the document to be persisted offline.

return useContext(YjsContext)?.doc ?? null
export function useYDoc(): Y.Doc {
const yjsCtx = useContext(YjsContext)
if (!yjsCtx) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does React guarantee that useEffect in YDocProvider will have been called before the component that invokes useYDoc is rendered? Otherwise this will be null even if it is in the provider on the first render, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are enforcing that by not rendering the Provider's children until the useEffect has run and the ctx !== null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, that makes sense, I can see how this is better!

@rolyatmax rolyatmax force-pushed the taylor/dis-1140-add-indexdb-integration-to-yjs-hooks branch from 3d4ef16 to 2d4115b Compare July 26, 2023 21:21
@vercel
Copy link

vercel bot commented Jul 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
y-serve ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2023 9:22pm

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

Successfully merging this pull request may close these issues.

None yet

2 participants