Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › cache is undefined

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22076

    Berka Frenfert

    I used same basic project Todo for learning but when i changed the url to get my documents

    I always get the cache undefined

    How do i tell storage that this time you are not getting Todo list rather Docs List will be used.

    Or please just explain what other than storage should be changed in Todo project when url is changed.

    here is the connections from DataModel

    Connections {
            id: logicConnection
    
            // action 1 - fetchTodos
            onFetchTodos: {
                // check cached value first
                ///YIB fucking code
                //var cached = cache.getValue("docs")
                var cached = cache.getValue("docs")
                if(cached)
                    _.todos = cached
    
                // load from api
                api.getTodos(
                            function(data) {
                                // cache data before updating model property
                                /// YIB
                                ///cache.setValue("todos",data)
                                cache.setValue("docs",data)
                                _.todos = data
                            },
                            function(error) {
                                // action failed if no cached data
                                if(!cached)
                                    fetchTodosFailed(error)
                            })
            }

    documentation does not explain that or if it does i could not find the detail So please consider this support the last place for help.

    waiting days for answer is certainly not right selection of software.

    #22078

    Alex
    Felgo Team

    Hi,

    with only that bit of code, it is hard to see what is going on. Also what do you mean with it being undefined? Is there no value set or is it actually and error that says “cache is undefined”? If the value is just empty, this will be due to the initialization code in the main file, which clears the cache if the app has internet access (and is therefore about to fetch the latest data):

    Component.onCompleted: {
        // if device has network connection, clear cache at startup
        // you'll probably implement a more intelligent cache cleanup for your app
        // e.g. to only clear the items that aren't required regularly
        if(isOnline) {
          logic.clearCache()
        }
    
        // fetch todo list data
        logic.fetchTodos()
        logic.fetchDraftTodos()
      }

    Cheers,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded