I have a backbone application that looks like this:
// Model for one picture
var Picture= Backbone.Model.extend({ });
// Model for Collection of Pictures
var Pictures = Backbone.Collection.extend({ model:Picture });
// Model for album
var Album = Backbone.Model.extend();
//Model for a collection of Albums
var Albums = Backbone.Collection.extend({ model:Album });
My server supports the following functions
List<Album> GetAlbums(List<Guid> albumIds);
List<Picture> GetPictures(albumId);
Dictionary<string, string> GetAlbumMetadata(albumId);
Dictionary<string, string> GetPictureMetadata(pictureId);
My page starts with one or more albums being loaded initially.
It should first get a list of albums.
Then it loads the metadata of all the albums.
Then it loads the pictures in each album.
Then it loads the metadata of each picture.
I cannot load all of it from a single server side call, because it is expensive, so I have to load it dynamically.
Is there a simple, backbone specific way of loading all this dynamically? Currently, I am reading the JSON returned on fetch() of each function, and then making the next function call based on the results returned from each call.
There has to be a more elegant way of doing this.