How to use the ember-runtime/mixins/controller.detect function in ember-runtime

To help you get started, we’ve selected a few ember-runtime 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 / streams / utils.js View on Github external
export function readUnwrappedModel(object) {
  if (isStream(object)) {
    let 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-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-views / lib / views / each.js View on Github external
_assertArrayLike: function(content) {
    Ember.assert(fmt("The value that #each loops over must be an Array. You " +
                     "passed %@, but it should have been an ArrayController",
                     [content.constructor]),
                     !ControllerMixin.detect(content) ||
                       (content && content.isGenerated) ||
                       content instanceof ArrayController);
    Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
                     [(ControllerMixin.detect(content) &&
                       content.get('model') !== undefined) ?
                       fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
                     EmberArray.detect(content));
  },
github emberjs / ember.js / packages / ember-handlebars / lib / helpers / each.js View on Github external
_assertArrayLike: function(content) {
    Ember.assert(fmt("The value that #each loops over must be an Array. You " +
                     "passed %@, but it should have been an ArrayController",
                     [content.constructor]),
                     !ControllerMixin.detect(content) ||
                       (content && content.isGenerated) ||
                       content instanceof ArrayController);
    Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
                     [(ControllerMixin.detect(content) &&
                       content.get('model') !== undefined) ?
                       fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
                     EmberArray.detect(content));
  },
github emberjs / ember.js / packages / ember-routing-views / lib / views / link.js View on Github external
if (attrs.disabledWhen) {
      this.set('disabled', attrs.disabledWhen);
    }

    if (!this[HAS_BLOCK]) {
      this.set('linkTitle', params.shift());
    }

    if (attrs.loadingClass) {
      set(this, 'loadingClass', attrs.loadingClass);
    }

    for (let i = 0; i < params.length; i++) {
      var value = params[i];

      while (ControllerMixin.detect(value)) {
        Ember.deprecate(
          'Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' +
            (attrs[RELATED_VIEW] ? 'Please update `' + attrs[RELATED_VIEW] + '` to use `{{link-to "post" someController.model}}` instead.' : ''),
          false,
          { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }
        );
        value = value.get('model');
      }

      params[i] = value;
    }

    let targetRouteName;
    let models = [];
    targetRouteName = this._computeRouteNameWithQueryParams(params[0]);
github emberjs / ember.js / packages / ember-views / lib / views / each.js View on Github external
_assertArrayLike: function(content) {
    Ember.assert(fmt("The value that #each loops over must be an Array. You " +
                     "passed %@, but it should have been an ArrayController",
                     [content.constructor]),
                     !ControllerMixin.detect(content) ||
                       (content && content.isGenerated) ||
                       content instanceof ArrayController);
    Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
                     [(ControllerMixin.detect(content) &&
                       content.get('model') !== undefined) ?
                       fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
                     EmberArray.detect(content));
  },
github emberjs / ember.js / packages / ember-routing-htmlbars / lib / helpers / link-to.js View on Github external
if (shouldEscape) {
      hash.layout = inlineEscapedLinkTo;
    } else {
      hash.layout = inlineUnescapedLinkTo;
    }

    hash.linkTitle = linkTitle;
  }

  for (var i = 0; i < params.length; i++) {
    if (isStream(params[i])) {
      var lazyValue = params[i];

      if (!lazyValue._isController) {
        while (ControllerMixin.detect(lazyValue.value())) {
          lazyValue = lazyValue.get('model');
        }
      }

      params[i] = lazyValue;
    }
  }

  hash.params = params;

  options.helperName = options.helperName || 'link-to';

  return env.helpers.view.helperFunction.call(this, [LinkView], hash, options, env);
}
github emberjs / ember.js / packages / ember-routing-views / lib / components / link-to.js View on Github external
_getModels(params) {
    let modelCount = params.length - 1;
    let models = new Array(modelCount);

    for (let i = 0; i < modelCount; i++) {
      let value = params[i + 1];

      while (ControllerMixin.detect(value)) {
        deprecate(
          'Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' +
            (this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''),
          false,
          { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }
        );
        value = value.get('model');
      }

      models[i] = value;
    }

    return models;
  },
github emberjs / ember.js / packages / ember-handlebars / lib / helpers / each.js View on Github external
_assertArrayLike: function(content) {
    Ember.assert(fmt("The value that #each loops over must be an Array. You " +
                     "passed %@, but it should have been an ArrayController",
                     [content.constructor]),
                     !ControllerMixin.detect(content) ||
                       (content && content.isGenerated) ||
                       content instanceof ArrayController);
    Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
                     [(ControllerMixin.detect(content) &&
                       content.get('model') !== undefined) ?
                       fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
                     EmberArray.detect(content));
  },