How to use the ember-runtime/system/object.extend 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-runtime / lib / system / each_proxy.js View on Github external
indicies[indexOf.call(indicies, loc)] = null;
    }
  }
}

/**
  This is the object instance returned when you get the `@each` property on an
  array. It uses the unknownProperty handler to automatically create
  EachArray instances for property names.

  @private
  @class EachProxy
  @namespace Ember
  @extends Ember.Object
*/
var EachProxy = EmberObject.extend({

  init: function(content) {
    this._super();
    this._content = content;
    content.addArrayObserver(this);

    // in case someone is already observing some keys make sure they are
    // added
    forEach(watchedEvents(this), function(eventName) {
      this.didAddListener(eventName);
    }, this);
  },

  /**
    You can directly access mapped properties by simply requesting them.
    The `unknownProperty` handler will generate an EachArray of each item.
github emberjs / ember.js / packages / ember-htmlbars / lib / helper.js View on Github external
});

Each time the input to a helper changes, the compute function will be called again.

As instances, these helpers also have access to the container and will accept injected dependencies.

Additionally, class helpers can call recompute to force a new computation.

@class Ember.Helper @public @since 1.13.0 */ var Helper = Object.extend({ isHelperInstance: true,

/** On a class-based helper, it may be useful to force a recomputation of that helpers value. This is akin to rerender on a component.

For example, this component will rerender when the `currentUser` on a
session service changes:

```js
// app/helpers/current-user-email.js
export default Ember.Helper.extend({
  session: Ember.inject.service(),
  onNewUser: Ember.observer('session.currentUser', function() {
    this.recompute();
  }),
github emberjs / ember.js / packages / ember-routing / lib / location / hash_location.js View on Github external
/**
@module ember
@submodule ember-routing
*/

/**
  `Ember.HashLocation` implements the location API using the browser's
  hash. At present, it relies on a `hashchange` event existing in the
  browser.

  @class HashLocation
  @namespace Ember
  @extends Ember.Object
*/
export default EmberObject.extend({
  implementation: 'hash',

  init() {
    set(this, 'location', get(this, '_location') || window.location);
  },

  /**
    @private

    Returns normalized location.hash

    @since 1.5.1
    @method getHash
  */
  getHash: EmberLocation._getHash,
github emberjs / ember.js / packages / ember-routing / lib / system / router_state.js View on Github external
import Ember from "ember-metal/core";
import EmberObject from "ember-runtime/system/object";
import merge from "ember-metal/merge";

var RouterState = EmberObject.extend({
  emberRouter: null,
  routerJs: null,
  routerJsState: null,

  isActiveIntent(routeName, models, queryParams, queryParamsMustMatch) {
    var state = this.routerJsState;
    if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { return false; }

    var emptyQueryParams = Ember.isEmpty(Ember.keys(queryParams));

    if (queryParamsMustMatch && !emptyQueryParams) {
      var visibleQueryParams = {};
      merge(visibleQueryParams, queryParams);

      this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams);
      return shallowEqual(visibleQueryParams, state.queryParams);
github emberjs / ember.js / packages / ember-runtime / lib / system / each_proxy.js View on Github external
addBeforeObserver,
  removeBeforeObserver,
  removeObserver
} from "ember-metal/observer";
import { typeOf } from "ember-metal/utils";
import { watchedEvents } from "ember-metal/events";
import { defineProperty } from "ember-metal/properties";
import {
  beginPropertyChanges,
  propertyDidChange,
  propertyWillChange,
  endPropertyChanges,
  changeProperties
} from "ember-metal/property_events";

var EachArray = EmberObject.extend(EmberArray, {

  init: function(content, keyName, owner) {
    this._super();
    this._keyName = keyName;
    this._owner   = owner;
    this._content = content;
  },

  objectAt: function(idx) {
    var item = this._content.objectAt(idx);
    return item && get(item, this._keyName);
  },

  length: computed(function() {
    var content = this._content;
    return content ? get(content, 'length') : 0;
github emberjs / ember.js / packages / ember-runtime / lib / system / deferred.js View on Github external
import Ember from 'ember-metal/core';
import DeferredMixin from "ember-runtime/mixins/deferred";
import EmberObject from "ember-runtime/system/object";

var Deferred = EmberObject.extend(DeferredMixin, {
  init: function() {
    Ember.deprecate('Usage of Ember.Deferred is deprecated.');
    this._super();
  }
});

Deferred.reopenClass({
  promise: function(callback, binding) {
    var deferred = Deferred.create();
    callback.call(binding, deferred);
    return deferred;
  }
});

export default Deferred;
github emberjs / ember.js / packages / ember-runtime / lib / system / namespace.js View on Github external
such as an application or framework. Create a namespace anytime you want
  to define one of these new containers.

  # Example Usage

  ```javascript
  MyFramework = Ember.Namespace.create({
    VERSION: '1.0.0'
  });

@class Namespace @namespace Ember @extends Ember.Object */ var Namespace = EmberObject.extend({ isNamespace: true,

init: function() { Namespace.NAMESPACES.push(this); Namespace.PROCESSED = false; },

toString: function() { var name = get(this, 'name'); if (name) { return name; }

findNamespaces();
return this[NAME_KEY];

},

nameClasses: function() {