question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offline Access Using Sync.

See original GitHub issue

Hey Guys,

I’m getting deep into integrating Realm Sync with my React Native app, ntwrk, which is currently running perfectly with a local-only Realm database.

I have the Realm Object Server running on a small Digital Ocean box with Ubuntu. I’m connecting to that Realm Object Server with both the simple Realm Browser and an XCode simulator running ntwrk. Everything works perfectly, with synching happening between the server, the simulator and the Realm Browser.

However, what I’m not understanding is how the offline-first is supposed to work. If I turn off the network connection to the simulator and refresh my app, it cannot connect to the Realm server and instead of using some locally cached Realm file until network access is restored, it gives an error TypeError: Network request failed.

Reading through the docs it doesn’t seem clear how to handle this appropriately.

Before I start rolling my own solution can you explain how to do this in the best way or point me to the docs that spell it out.

Many Thanks!

Joshua

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
joshuapintercommented, Apr 8, 2017

Just for others that might stumble upon this, here is the working code to use your offline local Realm User once they’ve authenticated for the first time online:

let user = Realm.Sync.User.current
if (user) {
  let synchedRealm = new Realm({
    sync: {
      user: user,
      url: 'realm://1.2.3.4:9080/~/my-realm',
    },
    schema: [Model1Schema, Model2Schema]
  });
  return synchedRealm;
}

// otherwise continue with login flow:

Realm.Sync.User.login('http://1.2.3.4:9080', 'test@email.com', 'password', (error, user) => {
//...

Bit of a discussion over at https://github.com/realm/realm-mobile-platform/issues/14#issuecomment-288487722 as well.

1reaction
noisypigeoncommented, Feb 10, 2017

Hey @joshuapinter. Thanks for reaching out. Someone will follow-up soon with some more information on your question. Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sync for Offline Access with the Desktop App - Egnyte Support
Open the Desktop App drive (or volume) from Window's File Explorer or Mac's Finder. Right click on the folder you want to sync...
Read more >
How to use offline files - Microsoft
Tap or click to open Sync Center. Select the Offline Files folder. Then, on the toolbar, tap or click Sync to sync all...
Read more >
Set up offline access to Docs editors - Google Support
To access your own files offline, see Work on Docs, Sheets, & Slides offline. ... Tell your users to how to sync files...
Read more >
Enable or Disable Offline Files in Windows 10 | Use it Correctly
Step 1. Open Sync Center again. Step 2. Click Offline Files folder, then you will see all the shared folders for offline files...
Read more >
How to enable Offline Files on Windows 10 - Pureinfotech
Optimize sync for slow connection ; Click the View by menu and select the Large icons option.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found