-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Node.js, React Native, Realm React, WASM
-
3 - M (<= 1 month)
-
5864
Problem
Standard way:
In this example we consider a case of Mobile and Server
For example, In Mobile there is collection called Tasks
Tasks has following fields
- uid
- name
- status
- priorities
i added a change listener to this object.
whenever i change these fields from my mobile, change listener tiggers and object or list i got from it will be sent to the server.
Perfect till now.
Problem:
when i get response. Here there are 2 scenarios
1. Nothing changed at server side
eg: i changed status to 1.
Req:
- uid :123232
- name: test
- status : 1
- priorities : 0
Res:
- uid :123232
- name: test
- status : 1
- priorities : 0
so i take this response and update in realm. Because both Objects are same, change listener will not trigger
2. something changed at server side
eg: i changed status to 1. Before i sent the request, someone changed priorities to 1 in the server.
Req:
- uid :123232
- name: test
- status : 1 //from me
- priorities : 0
Res:
- uid :123232
- name: test
- status : 1 // server updated response with what i sent
- priorities : 1 //sent fresh update which it has at server
so i take this response and update in realm using realm.create. Because both Objects are not same. change listener will trigger and says priorities changed
As of now point of truth to send response to the server is the change listener.
In this second scenario, it will keep on calling the server till both mobile side and server side copies are same.
In some scenarios mobile side and server side copies must not be same where i can save the number of calls.
Solution
To stop this. we need to have control on listeners when we use realm.create, like we have Modified.update, we should also have listen true/false
Alternatives
No response
How important is this improvement for you?
Dealbreaker
Feature would mainly be used with
Local Database only
- mentioned in
-
Page Loading...