Subsequent 'change' events not firing.
See original GitHub issueHi 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:
- Created 7 years ago
- Comments:20 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@appden Right. Thanks. Yeah, I actually had the
removeListener
on thecomponentWillUnmount
but removed it to test if that was causing issues. Had no effect.Let me know what you think. Thanks again. Really appreciate it.
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.