Zren / plasma-applet-githubissues

https://store.kde.org/p/1271237/
25 stars 5 forks source link

Lazy load LocalDb (LocalStorage cache) #16

Open Zren opened 4 years ago

Zren commented 4 years ago

Looks like qml-module-qtquick-localstorage isn't a default package. I didn't realized that as I forgot to release v3 for over a year.

Something like this to wrap the LocalDb functions if the item was loaded properly. If it has not (error loading the localstorage module) then it just calls fetch.

// LocalCache.qml
Loader {
    id: cache
    source: "LocalDb.qml"

    function get(key, fetchCallback, doneCallback) {
        if (item) {
            item.get(key, fetchCallback, doneCallback)
        } else {
            fetchCallback(key, doneCallback)
        }
    }
}