-
Notifications
You must be signed in to change notification settings - Fork 17
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 usage #120
Comments
Hi @adamski Currently for the first scenario mentioned, you will need to check your network status and either open a local realm accordingly and then copy over the data to the synced realm once an internet connection becomes available. You could also use a try-catch block on the If you already have a synced realm created and the I would do something like: First startup: auto user = app.login(realm::App::credentials::anonymous()).get();
auto flx_sync_config = user.flexible_sync_configuration();
auto synced_realm = experimental::db(flx_sync_config);
auto subs = synced_realm.subscriptions();
if (!subs.find("foo-strings")) {
synced_realm.subscriptions().update([](realm::mutable_sync_subscription_set &subs) {
subs.add<experimental::AllTypesObject>("foo-strings", [](auto &obj) {
return obj.str_col == "foo";
});
}).get();
}
synced_realm.write([&synced_realm]() {
...
}); Second startup (given that we have a valid user.) auto user = *app.get_current_user();
auto flx_sync_config = user.flexible_sync_configuration();
auto synced_realm = experimental::db(flx_sync_config);
synced_realm.write([&synced_realm]() {
...
}); |
Should it currently be possible to use a synced Realm instance offline?
If I run the app while offline for the first time (with no realm created yet),
open
throws an exception:http error code considered fatal. Server Error: 500
.If restart the app when offline (after realm has been created), it currently seems to block when calling
subscriptions.update
, reporting this sync errorFailed to connect to sync: Host not found (authoritative)
.If I go offline after successful startup (while online), and for example create a new document, I then get the sync error but it is non blocking. Is it possible to get this behaviour also when first opening a synced realm instance?
If not, what is the current recommended workaround? Should I manually check and instantiate a local vs synced instance depending on the connection status?
The text was updated successfully, but these errors were encountered: