简体   繁体   中英

When to write custom ember-data adapter?

I'm writing an ember application that pulls the majority of it's data from the Lastfm API. The API is not RESTful. I'm not sure what what level of abstraction I should customize. Should I go down the path of writing a custom LastFm ember-data adapter? Or should I just sidestep ember-data all together?

They return data similar to this:

{ "recenttracks" : { "meta" : {}, "tracks" : [ { track info }, { track info } ] } }

For requesting data, they have a scheme that involves sending a method parameter. So, not the worst thing ever, but certainly not RESTful.

Anyway, just looking for a bit of direction as I'm new to ember-data.

Thanks!

Personally, I would create a new adapter, not necessarily RESTAdapter , passing parameters to find and findAll :

var lastFmAdapter = DS.Adapter.create({
  find: function (store, type, id) { },
  findAll: function (store, type) { }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM