Пример #1
0
import BasicStream from 'ember-metal/streams/stream';
import {
  getArrayValues,
  getHashValues
} from 'ember-htmlbars/streams/utils';

let HelperInstanceStream = BasicStream.extend({
  init(helper, params, hash, label) {
    this.helper = helper;
    this.params = params;
    this.hash = hash;
    this.linkable = true;
    this.label = label;
  },

  compute() {
    return this.helper.compute(getArrayValues(this.params), getHashValues(this.hash));
  }
});

export default HelperInstanceStream;
import Stream from 'ember-metal/streams/stream';
import merge from 'ember-metal/merge';
import {
  getArrayValues,
  getHashValues
} from 'ember-htmlbars/streams/utils';

export default function BuiltInHelperStream(helper, params, hash, templates, env, scope, context, label) {
  this.init(label);
  this.helper = helper;
  this.params = params;
  this.templates = templates;
  this.env = env;
  this.scope = scope;
  this.hash = hash;
  this.context = context;
}

BuiltInHelperStream.prototype = Object.create(Stream.prototype);

merge(BuiltInHelperStream.prototype, {
  compute() {
    // Using call and undefined is probably not needed, these are only internal
    return this.helper.call(this.context, getArrayValues(this.params), getHashValues(this.hash), this.templates, this.env, this.scope);
  }
});