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

Offline modus or pending connect #156

Open
SebastianStehle opened this issue Sep 23, 2023 · 0 comments
Open

Offline modus or pending connect #156

SebastianStehle opened this issue Sep 23, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@SebastianStehle
Copy link

Checklist

[x] Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
[x] Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/

Is your feature request related to a problem? Please describe.

When a change happens and the provider is not connected yet and or currently offline, the change is lost.

Describe the solution you'd like

At the moment messages are only sent, when the websocket is available. Otherwise the update is just lost. The API also does not provide any methods to deal with initial connect in a nice way.

I have a react effect that connects to a y-sweet server whenever a ID changes. So it works like this:

React.useEffect(() => {
    const doc = new Y.Doc();
    const provider = createYjsProvider(...);
    init(doc, id);
}, [id]);

But when init is called, the doc is provider is not available yet. Therefore I had to wait for the connection to be established

React.useEffect(() => {
    const doc = new Y.Doc();
    const provider = createYjsProvider(...);
    await new Promise(resolve => {
            const handler = () => {
                if (provider.wsconnected) {
                    resolve(true);
                }
            };

            provider.on('status', handler);
        });
    init(doc, id);
}, [id]);

I think there should be a limited queue to handle this problem or network hiccups.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@SebastianStehle SebastianStehle added the enhancement New feature or request label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants