UNPKG

ember-render-helpers

Version:
32 lines (29 loc) 1.04 kB
import Helper from '@ember/component/helper'; import { assert } from '@ember/debug'; /** * This helper is activated immediately before the helper is un-rendered * (removed from the DOM). It does not run during or after initial render, or * when its arguments are updated. */ class WillDestroyHelperHelper extends Helper { callback; named; positional; compute(positional, named) { const [callback, ...positionalParameters] = positional; assert( // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `\`{{will-destroy-helper}}\` expects a function as the first parameter. You provided: ${callback}`, typeof callback === 'function'); this.callback = callback; this.named = named; this.positional = positionalParameters; } willDestroy() { if (this.callback && this.positional && this.named) { this.callback(this.positional, this.named); } super.willDestroy(); } } export { WillDestroyHelperHelper as default }; //# sourceMappingURL=will-destroy-helper.js.map