How to use the ember-metal/streams/utils.isStream function in ember-metal

To help you get started, we’ve selected a few ember-metal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / view.js View on Github external
for (var prop in hash) {
    var value = hash[prop];

    // Classes are processed separately
    if (prop === 'class' && isStream(value)) {
      hash.classBinding = value._label;
      delete hash['class'];
      continue;
    }

    if (prop === 'classBinding') {
      continue;
    }

    if (IS_BINDING.test(prop)) {
      if (isStream(value)) {
        Ember.warn("You're attempting to render a view by passing " +
                   prop + " " +
                   "to a view helper without a quoted value, " +
                   "but this syntax is ambiguous. You should either surround " +
                   prop + "'s value in quotes or remove `Binding` " +
                   "from " + prop + ".");
      } else if (typeof value === 'string') {
        hash[prop] = view._getBindingForStream(value);
      }
    } else {
      if (isStream(value) && prop !== 'id') {
        hash[prop + 'Binding'] = view._getBindingForStream(value);
        delete hash[prop];
      }
    }
  }
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / view.js View on Github external
function makeBindings(hash, options, view) {
  for (var prop in hash) {
    var value = hash[prop];

    // Classes are processed separately
    if (prop === 'class' && isStream(value)) {
      hash.classBinding = value._label;
      delete hash['class'];
      continue;
    }

    if (prop === 'classBinding') {
      continue;
    }

    if (IS_BINDING.test(prop)) {
      if (isStream(value)) {
        Ember.warn("You're attempting to render a view by passing " +
                   prop + " " +
                   "to a view helper without a quoted value, " +
                   "but this syntax is ambiguous. You should either surround " +
                   prop + "'s value in quotes or remove `Binding` " +
github emberjs / ember.js / packages / ember-views / lib / streams / utils.js View on Github external
export function readUnwrappedModel(object) {
  if (isStream(object)) {
    var result = object.value();

    // If the path is exactly `controller` then we don't unwrap it.
    if (object.label !== 'controller') {
      while (ControllerMixin.detect(result)) {
        result = get(result, 'model');
      }
    }

    return result;
  } else {
    return object;
  }
}
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / view.js View on Github external
continue;
    }

    if (IS_BINDING.test(prop)) {
      if (isStream(value)) {
        Ember.warn("You're attempting to render a view by passing " +
                   prop + " " +
                   "to a view helper without a quoted value, " +
                   "but this syntax is ambiguous. You should either surround " +
                   prop + "'s value in quotes or remove `Binding` " +
                   "from " + prop + ".");
      } else if (typeof value === 'string') {
        hash[prop] = view._getBindingForStream(value);
      }
    } else {
      if (isStream(value) && prop !== 'id') {
        hash[prop + 'Binding'] = view._getBindingForStream(value);
        delete hash[prop];
      }
    }
  }
}
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / bind-attr.js View on Github external
!element.getAttribute('class')
    );

    view.appendChild(classView);
  }

  var attrKeys = keys(hash);

  var attr, path, lazyValue, attrView;
  for (var i=0, l=attrKeys.length;i
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / binding.js View on Github external
function bind(property, hash, options, env, preserveContext, shouldDisplay, valueNormalizer, childProperties, _viewClass) {
  var valueStream = isStream(property) ? property : this.getStream(property);
  var lazyValue;

  if (childProperties) {
    lazyValue = new SimpleStream(valueStream);

    var subscriber = function(childStream) {
      childStream.value();
      lazyValue.notify();
    };

    for (var i = 0; i < childProperties.length; i++) {
      var childStream = valueStream.get(childProperties[i]);
      childStream.value();
      childStream.subscribe(subscriber);
    }
  } else {
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / partial.js View on Github external
export function partialHelper(params, hash, options, env) {
  options.helperName = options.helperName || 'partial';

  var name = params[0];

  if (isStream(name)) {
    options.template = createPartialTemplate(name);
    bind.call(this, name, hash, options, env, true, exists);
  } else {
    return renderPartial(name, this, env, options.morph.contextualElement);
  }
}
github emberjs / ember.js / packages / ember-routing-htmlbars / lib / helpers / action.js View on Github external
handler(event) {
      if (!isAllowedEvent(event, allowedKeys)) { return true; }

      if (options.preventDefault !== false) {
        event.preventDefault();
      }

      if (options.bubbles === false) {
        event.stopPropagation();
      }

      var target = options.target.value();

      var actionName;

      if (isStream(actionNameOrStream)) {
        actionName = actionNameOrStream.value();

        Ember.assert("You specified a quoteless path to the {{action}} helper " +
                     "which did not resolve to an action name (a string). " +
                     "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).",
                     typeof actionName === 'string');
      } else {
        actionName = actionNameOrStream;
      }

      run(function runRegisteredAction() {
        if (target.send) {
          target.send.apply(target, actionArgs(parameters, actionName));
        } else {
          Ember.assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === 'function');
          target[actionName].apply(target, actionArgs(parameters));
github emberjs / ember.js / packages / ember-htmlbars / lib / hooks / attribute.js View on Github external
export default function attribute(morph, env, attrName, attrValue) {
  if (boundAttributesEnabled) {
    var attrNode = new AttrNode(attrName, attrValue);
    attrNode._morph = morph;
    env.data.view.appendChild(attrNode);
  } else {
    if (isStream(attrValue)) {
      throw new EmberError('Bound attributes are not yet supported in Ember.js');
    } else {
      var sanitizedValue = sanitizeAttributeValue(env.dom, morph.element, attrName, attrValue);
      env.dom.setProperty(morph.element, attrName, sanitizedValue);
    }
  }
}