chrisben / imgcache.js

JS library based on the File API to cache images for offline recovery (target: cordova/phonegap & chrome)
Other
826 stars 216 forks source link

Allow constructing multiple caches #232

Closed oliversalzburg closed 5 years ago

oliversalzburg commented 6 years ago

This is not complete, but I wanted to submit it before someone else invests any work. Please note that I have yet to test any of this. I hope I can get back to it quickly.

Still missing:

I also wanted to keep the changes minimal, so I have not yet given any thought to how this might be applied ultimately or how code could be transitioned.

Closes #231

oliversalzburg commented 5 years ago

@chrisben Could you already have a look at this? It currently works as a drop-in replacement.

I'd now like to evaluate what sort of breaking changes are necessary or desirable to move forward.

The global ImgCache instance is currently the only instance of the ImgCache class. To maintain backwards compatibility, I could see adding a .constructNew(options) method on the ImgCache class, which would serve as a factory to create new caches.

What do you think?

oliversalzburg commented 5 years ago

I have now also tested this with my desired multi-cache use case and am very pleased with the results :) However, given the scope of this library, I might have missed something.