question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to get many items (aka. getItems())

See original GitHub issue

After doing some performance measurements on my app I notice I suffer a lot from doing this:

localForage.getItem('all_ids', function(ids) {
    _.each(ids, function(id) {
        localForage.get(id, function(value) {
            ...
        });
    })
})

This is causing a lot of excess work for the browser if the list is long (e.g. 1,000+).

I know the localStorage spec doesn’t have support getItems() but in most cases IndexDB is supported and it appears to have low level support for getting multiple keys which could hopefully reduce the overhead in total.

For the localStorage fallback, this would be trivial to wrap up with a for loop of kinds.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:28 (20 by maintainers)

github_iconTop GitHub Comments

8reactions
tofumattcommented, Oct 28, 2014

@thgreasi wrote in #291 an API I like for these multi-item calls:

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.

2reactions
tamer1ancommented, Jul 23, 2017

Yes, it would be convenient. Please consider adding that feature. :godmode:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parse outputs('Get_items_2')?['body/value']
Solved: Hello, so I've got a Get List with a filter that should give me only 1 ... inside this true branch, assign...
Read more >
DynamoDB Python Boto3 Query Cheat Sheet [14 Examples]
This cheat sheet covers the most important DynamoDB Boto3 query examples that you can use for your next DynamoDB Python project.
Read more >
Arrays and collections in Power Automate, 1 awesome post
Today I was asked about how arrays (aka collections) work in Microsoft Flow. In this post I will shed some light on arrays...
Read more >
Super Simple flow to get more than 5000 SharePoint Items
Super easy method to get more than 5000 items from a SharePoint list using Power Automate with incredible performance.
Read more >
How to find the size of localStorage - Stack Overflow
The same code in multiple lines for reading sake ... You can get the current size of the local storage data using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found