angular-restmod icon indicating copy to clipboard operation
angular-restmod copied to clipboard

.singleton(url, {mix}) causes deprecation "use restmod.model().mix() instead" warning.

Open nexorianus opened this issue 8 years ago • 1 comments

Using version v1.1.11 of restmod, we tried to use a singleton model.

like so:

restmod.singleton(url, 
    {
        // ...
    }
);

But this issues a warning Passing mixins and definitions in the model method will be deprecated in restmod 1.2, use restmod.model().mix() instead. This is because the .singleton is only a shorthand that returns back to the normal model, that has the warning.

Sadly I could not get it to work with neither: restmod.singleton('url').mix({...}) nor restmod.model(null).single(url).mix({...}).

The documentation does not really state how to work with those, and also is not up to date regarding the deprecation warning.

Question: How do I solve the deprecation within a singleton?

Further code analysis in angular-restmod.js line 178

singleton: function(_url/*, _mix */) {
    return restmod.model.apply(this, arguments).single(_url);
}

resolves to angular-restmod.js line 133

model: function(_baseUrl/* , _mix */) {
  var model = buildModel(_baseUrl, BASE_CHAIN);

  if(arguments.length > 1) {
    model.mix(arraySlice.call(arguments, 1));
    $log.warn('Passing mixins and definitions in the model method will be deprecated in restmod 1.2, use restmod.model().mix() instead.');
  }

  return model;
}

causing the warning. with arguments containing two elements:

  1. the url
  2. the mix Object

nexorianus avatar Mar 22 '17 07:03 nexorianus

For now, the best 'fix' for it would be to not use the singleton method and just call the methods yourselfs:

restmod.model().mix(...).single(url)

The singleton could should be rewritten to this. But due to the abandoned state of the library, I don't think this will ever happen. I don't know how many people actively use this library.

ebuzzz avatar Aug 22 '18 07:08 ebuzzz