@JordanRDesigns wrote:
I'm using
queryto get items from my API, however when I come back to the route that loaded the data from the API I'm seeing a network call everytime. I want to prevent that. So I saw there is ashouldReloadAllandshouldBackgroundReloadAllthat I could use to tell it to only background reload records if say it's passed a certain time. However, those methods only appear to work forfindandfindAll.My model hook looks like this
var self = this; return this.store.query('item',{user_id: self.get('localUser.user.id'),status:1}).then(function(result){ if(result){ return result; } else { self.get('notification').notify({message: "An error occurred trying to get your watch list.",success:false}); self.transitionTo('home'); } });Which gets turned into
http://my.site/api/items/user/13193?status=1&key=XXXXwith an adapter functionajax: function(url, type, hash) { if (Ember.isEmpty(hash)) hash = {}; if (Ember.isEmpty(hash.data)) hash.data = {}; if (hash.data.auction_id) { url = url + '/event/'+hash.data.auction_id; delete hash.data.auction_id; } if (hash.data.user_id) { url = url + '/user/'+hash.data.user_id; delete hash.data.user_id; } return this._super(url, type, hash); }(Yes the API I'm working with right now is really weird, I have plans to fix it later but don't have green light to do so right now)
Most importantly right now I want to save the network call if I've already loaded items from the store.
Here's the kicker, this call here is for
watch-listitems. There is another routeitemswhich loads items using theactive_auctionquery param as seen in theajaxfunction in the adapter. So both of those are calling up items but they are different sets of items. So whenitemsloads items it should cache those separately from the items thatwatch-listshould cache. And when I enter either route it should check only for cached items in the store relevant to that particular URL.So things here are a little confusing, can anyone help me?
Posts: 1
Participants: 1