Coder Social home page Coder Social logo

Comments (9)

scotttrinh avatar scotttrinh commented on September 14, 2024 1

I have an idea, but it'll probably be a day or two before I have tests written, a fix implemented and a new version published. If you're cool the hang out for a few days while that gets patched, I'll just let you know when it's fixed.

from angular-localforage.

scotttrinh avatar scotttrinh commented on September 14, 2024

@Adavo I don't think you should have to stringify your object to get good performance. I'll take a look. Do you have a sense of just how big the object is? Could you share the code you're using that seems to be causing the blocking?

from angular-localforage.

scotttrinh avatar scotttrinh commented on September 14, 2024

I think I see the performance issue: https://github.com/ocombe/angular-localForage/blob/master/src/angular-localForage.js#L125

We're copying the whole object in order to remove $promise if it's present. Seems like we can do something smarter here and get a huge performance boost for large object storage. I'll put something together and let you know. In the meantime, if you can get by with stringifying and parsing your object that'll do.

Thanks for bringing this up! Can't wait to fix this for my own purposes, too.

from angular-localforage.

Adavo avatar Adavo commented on September 14, 2024

from angular-localforage.

Adavo avatar Adavo commented on September 14, 2024

Now, I store the big object as a blob and it's very efficient. I will continue with that solution but still interesting to know when this performance issue is fixed ;-)

from angular-localforage.

scotttrinh avatar scotttrinh commented on September 14, 2024

@Adavo

Glad blob storage ended up being a good optimization for you. I've fixed the copying issue, do you mind trying it out with the new version (1.4.4) and tell me if that works better than before?

from angular-localforage.

Adavo avatar Adavo commented on September 14, 2024

from angular-localforage.

Adavo avatar Adavo commented on September 14, 2024

I was so curious that I couldn't wait tomorrow.
Good point, saving the whole object is faster than before, which prevent the app to freeze a long time (instead of freezing like 6sec is more like 2sec, which is quite impressive).
It's similar to blob so I think this bug is "fixed" ;-)

For reference, my object is an array of 114328 objects like this one:
{
frequency: 7
hanzi:"干"
isNew:false
pinyin:"gān"
translations: {
en-US:"old variant of 干[gān]"
}
}

As I still have like 2sec of latency, I may try if time to use a service worker to avoid DOM freeze. Maybe the lib can manage this by itself, one day ... ;-)

from angular-localforage.

scotttrinh avatar scotttrinh commented on September 14, 2024

@Adavo

Excellent, I'm glad that gave you performance comparable to storing a blob! I'd be interested in using Web Workers to keep from blocking the main thread, so stay tuned.

from angular-localforage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.