Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-566

Realm write won't write on main thread in IOS

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      <!---

      Questions: If you have questions about HOW TO use Realm, please ask on
      StackOverflow: http://stackoverflow.com/questions/ask?tags=realm
      We monitor the realm tag.

      Feature Request: Just fill in the first two sections below.

      Bugs: To help you as fast as possible with an issue please describe your issue
      and the steps you have taken to reproduce it in as much detail as possible.

      -->

      <!--- What did you expect to happen? -->

      getDogs().then((result) => {
              const realm = this.state.realm;
              realm.write(() => {
                const allDogs = realm.objects('Dogs');
                realm.delete(allDogs);
                console.log('realm write');
                result.mails.forEach((element) => {
                  realm.create(
                    'Dogs',
                    {
                      id: element.id,
                      date: element.date,
                      name: element.name,
                    },
                    true
                  );
                });
              });
              this.setState({ dogs: realm.objects('Dogs'), errorMessage: null });
            })
            .catch((error) => {
              this.log(error);
            });
      

      Actual Results

      Should have stored dogs in state. Works on android. Gets generalised message on iOS
      [info][tid:com.facebook.react.JavaScript]

      {"line":103419,"column":27,"sourceURL":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"}

      The same line works in constructor or render method.

      P.S. The method is called from a button click.

      Version of Realm and Tooling

      • Realm JS SDK Version: 5.0.4
      • Node or React Native: React Native
      • Client OS & Version: iphone 11 - 13.3 simulator
      • Which debugger for React Native: None

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: