engine icon indicating copy to clipboard operation
engine copied to clipboard

Async helpers support

Open tunnckoCore opened this issue 7 years ago • 1 comments

Will be good to support it out of the box.

With https://github.com/doowb/async-helpers/pull/19 it will be nothing more than just calling its .set. If the helper is regular async or callback async function it will be handled/wrapped by the async-helpers, otherwise it will be just set in the this.helpers. With .get() you will get both the wrapped and non-wrapped ones.

tunnckoCore avatar Nov 14 '18 09:11 tunnckoCore

  helper(prop, fn) {
    if (utils.isObject(prop)) {
      this.helpers(prop);
    } else {
      this.asyncHelpers.set(prop, fn);
    }
    return this;
  }

  helpers(helpers) {
    this.asyncHelpers.set(helpers);
    return this;
  }

  // later merge `this.imports` and `this.asyncHelpers.helpers`

Probably would be good thing to just rename the this.helpers in async-helpers to be this.imports so will be able to extend the AsyncHelpers class here.

tunnckoCore avatar Nov 14 '18 10:11 tunnckoCore