0
votes

Is there some ember-data alternative framework that can work with 'bootstrap resources'?

When my ember application loads, it downloads initial data from 'bootstrap' resource. That resource contains some basic information - for examle resource returns list of books and each book contains only title and author name. As user navigates to some book, I'd like to download more info about that book and show it.

The problem is that I'd like to have only single model representation of the book (to avoid synchronizaion between some BookModel and BookInfoModel).

So basically what I want is some BookModel which keeps information that it is only partially loaded(from bootstrap resource) and if I request BookModel itself, it's load the rest from server.

Is that somehow possible?

1

1 Answers

0
votes

If I get your question right a possible setup like the following should work, it will lazy load your BookModelInfo data only when needed:

App.Adapter = DS.RESTAdapter.extend();

App.BookModel = DS.Model.extend({
  bookModelInfo: DS.hasMany('App.BookModelInfo'),
  ...
});

App.BookModelInfo = DS.Model.extend({
  bookModel: DS.belongsTo('App.BookModel'),
  ...
});

App.Adapter.map('App.BookModel', {
  bookModelInfo: {embedded: 'load'}
});

As you can see I've defined a one to many relation because for the time beeing ember data does not support one to one relations, but I guess this way it will be also usable for your use case.

Hope it helps.