Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nexorianus opened this issue Mar 22, 2017 · 1 comment

Comments

@nexorianus
Copy link

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
@ebuzzz
Copy link

ebuzzz commented Aug 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants