realm-js
realm-js copied to clipboard
Incorrect Results Delete Change Notifications
Goals
- Provision of correct fine grained change notifications for Results instances upon deletes.
- Expected Results
- I expected that upon removing the first instance from a Results instance like this
const firstObjectOfType = realm.objects('Dog')[0];
realm.write(() => {
realm.delete(firstObjectOfType);
});
- I would get this for changes notifications:
{
insertions: [],
deletions: [0],
modifications: []
}
Actual Results
- Instead I got this for changes notifications
{
insertions: [0],
deletions: [0, <index of last element(i.e. if length 3 then index 2)>],
modifications: []
}
- This is occurring for Results whose length is greater than 2 for whatever reason.
- So it only works for a Results set of lengths 1 and 2.
Steps to Reproduce
- With provided code sample or one of your own do the following:
- Add at least 3 objects of a type(i.e. click the Add Rex button 3 times)
- Remove the first resource(i.e. click the Remove First button 1 time)
- Code Sample
- Gist of Root Component to Register with React Native
Version of Realm and Tooling
- Realm JS SDK Version: 2.0.12
- Node: 8.6.0
- React Native: 0.50.4
- Client OS & Version: 10.12.6
- Which debugger for React Native: Chrome Remote Debugger