Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getItems() / setItems() methods would be nice #291

Closed
yuriy-yarosh opened this issue Oct 28, 2014 · 3 comments
Closed

getItems() / setItems() methods would be nice #291

yuriy-yarosh opened this issue Oct 28, 2014 · 3 comments

Comments

@yuriy-yarosh
Copy link

I'm facing a lack of multiple entities fetching possibility, so I have to sync getting the last one manually.
It's not so tricky, but I think it would be a simple improvement.

@thgreasi
Copy link
Member

How about:

Promise.all([
    localforage.getItem('item1'),
    localforage.getItem('item2')
]).then(function(results) {
    console.log(results);
});

// OR

var items = ['item1', 'item2', 'item3'];
var promises  = items.map(function(item) { return localforage.getItem(item); });
Promise.all(promises).then(function(results) {
    console.log(results);
});

If getItems() / setItems() are going to be implemented by localforage at some point, then something like the 2nd example might actually have to be used by some drivers.

@yuriy-yarosh
Copy link
Author

Well, I do not use promises, but chaining promises is much more simplier than chaining callbacks.

@tofumatt
Copy link
Member

This has been brought up in #21. I definitely want this in the future (see the milestone for 1.2 that actually references it).

I've copied @thgreasi's code example to that issue; let's keep the discussion going over there to prevent duplicate issues. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants