coalescejs / coalesce

A modern client-side persistence framework
MIT License
32 stars 11 forks source link

session.query optimization for offline mode, returning fetchquery if one exists #7

Open cheneveld opened 9 years ago

cheneveld commented 9 years ago

We are playing with this paradigm in route model hooks in ember:


 model: function() {
        var self = this;
        return this.session.query('user').then(function(users){
            return users;
        }, function(error){
          console.error("Application::query('user') failed, now calling fetchQuery");
          return self.session.fetchQuery('user');
        });
    },

Would it make any sense for query to return the fetchQuery result if one exists when query fails? Or should we keep this logic on the app side?

ghempton commented 9 years ago

I think for now we should just keep the logic on the app side. I can see it failing outright being desirable for online applications. One option here would be to allow applications to have a custom query cache implementation that can be offline aware.