AsyncStorage.multiGet()

static multiGet(keys, callback?)

multiGet invokes callback with an array of key-value pair arrays that matches the input format of multiSet. Returns a Promise object.

multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']])

Example:

AsyncStorage.getAllKeys((err, keys) => {
  AsyncStorage.multiGet(keys, (err, stores) => {
   stores.map((result, i, store) => {
     // get at each store's key/value so you can work with it
     let key = store[i][0];
     let value = store[i][1];
    });
  });
});
doc_React_Native
2016-06-23 04:23:40
Comments
Leave a Comment

Please login to continue.