Forums

OverviewFelgo 2 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support