Skip to content

Update Custom Registries example code #2561

@jeanbmar

Description

@jeanbmar

Task functions medata are lost when using fn.bind as in:

ConfigRegistry.prototype.set = function set(name, fn) {
  // The `DefaultRegistry` uses `this._tasks` for storage.
  var task = this._tasks[name] = fn.bind(this.config);
  return task;
};

Updating the example with the following would preserve metadata:

ConfigRegistry.prototype.set = function set(name, fn) {
  // The `DefaultRegistry` uses `this._tasks` for storage.
  var task = this._tasks[name] = Object.assign(fn.bind(this.config), fn);
  return task;
};

It's not a big deal but it would definitely save some times to devs wondering why metadata aren't displaying suddenly :).

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