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.

Subsequent 'change' events not firing.

See original GitHub issue

Hi guys,

I’m using Realm’s ListView and an event listener to monitor for changes to the data and updating my ListView.

Oddly, it works fine on the first change to the data (e.g. adding a record or deleting a record) but on subsequent changes the event doesn’t seem to fire.

Here’s my setup:

constructor(props) {
  super(props);

  var dataSource = new ListView.DataSource(
    { rowHasChanged: (r1, r2) => r1 !== r2 } );

  this.state = {
    dataSource: dataSource.cloneWithRows(this.getRecords())
  };

  Realm.addListener('change', () => {
    console.log("Realm Changed!");

    this.setState({
      dataSource: dataSource.cloneWithRows(this.getRecords())
    })
  });
}

When I first add (or delete) a record, I see Realm Changed! in my console. However, if I add (or delete) a subsequent record, I don’t see this console message.

Any idea why this could be?

Thanks!

Josh

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
joshuapintercommented, May 11, 2016

@appden Right. Thanks. Yeah, I actually had the removeListener on the componentWillUnmount but removed it to test if that was causing issues. Had no effect.

Let me know what you think. Thanks again. Really appreciate it.

0reactions
joshuapintercommented, Jun 19, 2016

Okay, I feel like a bit of a dum dum. On a nested page I was using Realm.removeAllListeners(); instead of removing just the listener for that page.

I’m having trouble using removeListener effectively but I’ll create a new issue for that.

Thanks for all your help. I’m closing this off now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Change event not firing on textbox when data is ...
My use case here is that I need to change elements on a form whenever a particular textbox changes value. The problem is...
Read more >
Change data capture event not firing associated trigger in ...
I have a custom trigger that fires on an OpportunityChangeEvent: trigger EXAMPLE_CREATE on OpportunityChangeEvent(after insert) { // Get the ...
Read more >
Change event not fired when complex object modified - IBM
Subsequently modifying an existing value in the object results in the change event firing and placing the previously incorrect display in the correct...
Read more >
Firing Events - Testing Library
Convenience methods for firing DOM events. ... This is particularly useful for a change event: ... Otherwise the element will not
Read more >
SCR19: Using an onchange event on a select element ... - W3C
This technique will not cause a change of context. When there are one or more ... param selectObj - the select object which...
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