Skip to content

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

@nexorianus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions