In the Ember JS Application Guide, the author shows how to show a list of shoes and then eventually just show one shoe.
The problem, is in his example, he mimics a slow JSON request (using setTimeout) to get ALL shoes but then he just refers directly to the object literal to show one shoe.
My question: What is the appropriate approach to pull data using JSON once for a collection of items, then refer to the downloaded collection for other methods (i.e Show one shoe)
I don’t need it to be persistent across sessions, just work until the user closes the browser/tab.
In the example, the
setTimeoutcallback places the collection intoApp.Shoe, which is a global object. You can access it any time after that usingApp.Shoe._listOfShoes. So, if you just want to load the collection once and then re-use it, you could add confirm before making the request, whether the data has already been loaded. That is, something like: