Code -
I am checking if an entry named listobject exists in AsyncStorage.
If it does not exist, I create an object, add several attributes and install the repository. I get obj storage as I need to compare the following if condition .
If the listobject entry already exists (second time), then it goes directly to the second block and is compared. (The reason I get the values for obj in the first step is because I can have the general condition obj.data.isdirty .
Here is my code -
AsyncStorage.getItem('listobject').then((obj) => { if(obj == undefined) { var obj1 ={}; obj1.data ={}; obj1.data.isdirty = true; console.log("obj1 = "+ JSON.stringify(obj1)); AsyncStorage.setItem('listobject',obj1); obj = AsyncStorage.getItem('listobject'); console.log("obj = "+ JSON.stringify(obj)); } if(obj.data.isdirty) { obj.data.isdirty = false; AsyncStorage.setItem('listobject',JSON.stringify(obj)); return AsyncStorage.getItem('listobject'); } }).done();
I have 2 questions that are the result of the same problem -
12-03 00: 27: 56.281 32598-487/com.abc D/ReactNativeJS: 'obj1 = { "data": { "isdirty": true}}'12-03 00: 27: 56.286 32598-487/com.abc D/ReactNativeJS: 'obj = { "_37": 0, "_ 12": null, "_ 59": []}'
12-03 00: 27: 56.281 32598-487/com.abc D/ReactNativeJS: 'obj1 = { "data": { "isdirty": true}}'
12-03 00: 27: 56.286 32598-487/com.abc D/ReactNativeJS: 'obj = { "_37": 0, "_ 12": null, "_ 59": []}'
undefined ( "list.data.isdirty" );
, , ?
. .
AsyncStorage.getItem('listobject').then((obj) => { if(obj == undefined) { var obj1 ={}; obj1.data ={}; obj1.data.isdirty = true; console.log("obj1 = "+ JSON.stringify(obj1)); AsyncStorage.setItem('listobject',obj1); obj = obj1; //THIS IS WHAT I DID! console.log("obj = "+ JSON.stringify(obj)); } if(obj.data.isdirty) { obj.data.isdirty = false; AsyncStorage.setItem('listobject',JSON.stringify(obj)); return AsyncStorage.getItem('listobject'); } }).done();
, AsyncStorage. , Async , . , getItem (), , Promise, , .
obj = AsyncStorage.getItem('listobject'); console.log("obj = "+ JSON.stringify(obj));
obj .
obj
, obj isDirty child, Promise.
Source: https://habr.com/ru/post/1618326/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1618321/what-all-places-to-verify-file-upload-size-limit&usg=ALkJrhia-5x389wDPLFwxJ6Nk5nvbr7GrQIIS Express 8 - Maximum Allowed Length - c #Socket.io + node.js + express + ssl + Nginx - клиент не будет подключаться - 400 (неудачный запрос) - node.jsReact Native Navigator - the screen is always blank - javascriptHibernate 5, JPA 2.0 Web Web - springCSS Radial Gradient Shade - Back - cssDeploying an application using Hibernate JPA 2.1 for IBM WebSphere gives a NullPointerException - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1618329/how-do-i-assign-a-child-class-to-a-generic-field-in-a-non-generic-class&usg=ALkJrhhZAm4hN2MIymEMFUOpRM2dpJBAAAList of users with a list of roles in Identity 2.2.1 - c #java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey () Ljavax / persistence / ForeignKey; - hibernateAll Articles