plasma-applet-githubissues icon indicating copy to clipboard operation
plasma-applet-githubissues copied to clipboard

Lazy load LocalDb (LocalStorage cache)

Open Zren opened this issue 5 years ago • 0 comments

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)
        }
    }
}

Zren avatar May 22 '20 21:05 Zren