Skip to content

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

Description

@nexorianus

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

Activity

  1. ebuzzz commented on Aug 22, 2018

    @ebuzzz

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions