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.

addListener notification is empty (documentation only)

See original GitHub issue

When using addListener(objects, changes) on React Native iOS it always returns empty on the first notification and the second notification returns what should have been in the first one.

I found in results-tests.js below that first notification is empty.

Is this by design or am I doing something wrong here? 😀

        realm.objects('TestObject').addListener((testObjects, changes) => {
            // TODO: First notification is empty, so perform these
            // assertions on the second call. However, there is a race condition
            // in React Native, so find a way to do this in a robust way.
            //TestCase.assertEqual(testObjects.length, 4);
            //TestCase.assertEqual(changes.insertions.length, 1);
            resolve();
        });

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:10
  • Comments:27 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
lamflamcommented, Jul 27, 2017

@sheshavpd This was a critical issue for me as well, and for now I got it working by doing realm.write(() => {}) (basically a second empty write) after each write. Far from ideal and may not be feasible in your context, but it’s been working well for me in the meantime.

3reactions
kosiakMDcommented, Sep 27, 2017

Realm: 1.12.0 RN: 0.47 Platform: iOS 11 BUT only in simulator - on iPhone SE no problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'addEventListener' of null - Stack Overflow
I think the easiest approach would be to just check that el is not null before adding an event listener: var el =...
Read more >
ServiceWorkerGlobalScope: notificationclick event - Web APIs
This value returns an empty string if the user clicked the notification somewhere other than an action button, or the notification does not...
Read more >
SDK Notification Event Handlers - OneSignal Documentation
OneSignal SDK setNotificationOpenedHandler method runs upon opening the app after a notification is clicked. Background Notification Received Event, Native ...
Read more >
Scripting API: Events.UnityEvent.AddListener - Unity - Manual
Use this to add a runtime callback. Adding multiple identical listeners results in only a single call being made. //Attach this script to...
Read more >
Notifications - Expo Documentation
Custom notification sounds are only supported when using EAS Build, or in the bare ... addEventListener('url', onReceiveURL); // Listen to expo push ...
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