Local Realm open after synchronized on realm cloud

hmm okay ! Please comment here if you manage to find solution. Thanks !

Nothing has changed significantly on that front in v10. Your code should look something like:

async function getRealm() {
    const app = new Realm.App("your-app-id");
    if (app.currentUser) {
        // A user had already logged in - open the Realm synchronously
        return new Realm(getConfig(app.currentUser));
    }

    // We don't have a user - login a user and open the realm async
    const user = await app.logIn(Realm.Credentials.anonymous());
    return await Realm.open(getConfig(user));
}

function getConfig(user) {
    return {
        sync: {
            user,
            partitionValue: "my-partition"
        }
    };
}
3 Likes

look, its seems be easy, im did this, but i have a problema, look here

Thanks for your comment. I have code similar to yours. But unfortunately, when I open my app with internet off, it does not return anything. It just returns empty array.

Same happens with my app. When I open my app with internet off, it returns nothing .

check your cached user logic, use like @nirinchev code

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.