{"repo":"sunnylqm/react-native-storage","free":true,"listed":false,"github":"https://github.com/sunnylqm/react-native-storage","clone":"git clone https://github.com/sunnylqm/react-native-storage.git","description":"local storage wrapper for both react-native and browser. Support size controlling, auto expiring, remote data auto syncing and getting batch data in one query.","language":"JavaScript","stars":3038,"topics":["localstorage","asyncstorage","react-native","reactjs","sync"],"license":"MIT","category":"mobile-apps","readme_excerpt":"react-native-storage This is a local storage wrapper for both react native apps (using AsyncStorage) and web apps (using localStorage). ES6 syntax, promise for async load, fully tested with jest. For a more modern and unified approach to handling requests, caching, and persistent storage, I recommend using useQuery together with createAsyncStoragePersister . It’s cleaner, more elegant, and more powerful. 查看中文文档请点击 README-CHN.md Install or Usage Init Save & Load & Remove Sync remote data(refresh) There are two ways to set the sync method. You can pass the sync method in the constructor's parameter, as a function in an object, or you can define it at any time as shown below: In the following example the sync method is called, when you invoke storage.load : If there is no user 1002 currently in storage, then storage.sync.user will be invoked to fetch and return the remote data. Load batch data There is an important difference between the way these two methods perform: getBatchData will invoke separate sync methods for each different key one after the other when the corresponding data is missing or not in sync. However, getBatchDataWithIds will collect a list of the missing data, pushing their ids to an array, and then pass the array to the single corresponding sync method once, reducing the number of requests, so you need to implement array query on the server side and handle the parameters of sync method properly. Note that the id parameter can be a single string or an array of","default_branch":null,"files":null,"tree":[],"storefront":"/r/sunnylqm","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sunnylqm/react-native-storage/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}