reactiveweb
    Preparing search index...

    Function helper

    • implemented with raw invokeHelper API, no classes from ember-resources used.


      Enables the use of template-helpers in JavaScript

      Note that it should be preferred to use regular functions in javascript whenever possible, as the runtime cost of "things as resources" is non-0. For example, if using @ember/component/helper utilities, it's a common p practice to split the actual behavior from the framework construct

      export function plainJs() {}

      export default helper(() => plainJs())

      so in this case plainJs can be used separately.

      This differentiation makes less of a difference since plain functions as helpers will be supported soon.

      Type Parameters

      • T = unknown
      • S = InferSignature<T>
      • Return = Get<S, "Return", unknown>

      Parameters

      • context: object
      • helper: T
      • thunk: Thunk = DEFAULT_THUNK

      Returns { value: Return }

      import intersect from 'ember-composable-helpers/addon/helpers/intersect';

      import { helper } from 'reactiveweb/helper';

      class Demo {
      @tracked listA = [...];
      @tracked listB = [...]

      intersection = helper(this, intersect, () => [this.listA, this.listB])

      toString = (array) => array.join(', ');
      }
      {{this.toString this.intersection.value}}