Share adapter across multiple models

Hi,

I’ve got several RESTAdapters that are exactly the same. Is it possible to share one adapter across multiple models?

I’ve created one super-RESTAdapter that all the others inherit from, but now I’ve got a bunch of empty adapters, which is awful,…

thanks

Can you just create an application adapter? It should cover all models.

I just want the adapter to be used on a certain models, not all of them

Depending on what you’re doing, the methods you’re overriding (e.g. normalizeResponse) could just detect the model based on a whitelist else call this._super instead? Can you share an example?

thanks for a reply

I am overriding methods:

  • shouldReloadAll
  • shouldBackgroundReloadAll
  • shouldReloadRecord
  • shouldBackgroundReloadRecord

my code:

import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({

  findAllPerformed: false,

  shouldReloadAll(store, snapshotRecordArray) {
        //something here
  },
  shouldBackgroundReloadAll(){
    return false;
  },

  shouldReloadRecord(){
    return false;
  },

  shouldBackgroundReloadRecord: function(store, snapshot) {
    return false;
  }
});