How to use the ember-compatibility-helpers.gte function in ember-compatibility-helpers

To help you get started, we’ve selected a few ember-compatibility-helpers 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 DockYard / ember-router-scroll / addon / index.js View on Github external
} else if (scrollWhenPainted) {
      // as described in ember-app-scheduler, this addon can be used to delay rendering until after First Meaningful Paint.
      // If you loading your routes progressively, this may be a good option to delay scrollTop until the remaining DOM elements are painted.
      whenRoutePainted().then(() => {
        this.updateScrollPosition(transition);
      });
    } else {
      // as described in ember-app-scheduler, this addon can be used to delay rendering until after the route is idle
      whenRouteIdle().then(() => {
        this.updateScrollPosition(transition);
      });
    }
  }
});

if (!gte('3.6.0-beta.1')) {
  RouterScrollMixin = Mixin.create(RouterScrollMixin, {
    willTransition(...args) {
      this._super(...args);

      this._routeWillChange();
    },

    didTransition(transitions, ...args) {
      this._super(transitions, ...args);

      this._routeDidChange(transitions);
    }
  });
}

export default RouterScrollMixin;
github glimmerjs / glimmer.js / packages / @glimmer / component / addon / index.ts View on Github external
function defineErrorProp(proto, key, getterMethod) {
    Object.defineProperty(proto, key, {
      get: () => getterMethod(key),
      set(value) {
        Object.defineProperty(this, key, { value });
      },
    });
  }

  // Methods should still throw whenever they are accessed
  defineErrorProp(proto, 'bounds', throwPropertyUseError);
  defineErrorProp(proto, 'element', throwPropertyUseError);
  defineErrorProp(proto, 'debugName', throwPropertyUseError);
}

if (gte('3.8.0-beta.1')) {
  setComponentManager((owner: ApplicationInstance) => {
    return new GlimmerComponentManager(owner);
  }, GlimmerComponent);
} else {
  setComponentManager('glimmer', GlimmerComponent);
}

export default GlimmerComponent;
github ember-decorators / ember-decorators / packages / controller / addon / index.js View on Github external
```javascript
  import Controller from '@ember/controller';
  import { inject as controller } from '@ember-decorators/controller';

  export default class IndexController extends Controller {
    @controller application;
  }

@function @param {string} controllerName? - The name of the controller to inject. If not provided, the property name will be used @return {Controller} */ export let inject;

if (gte('3.10.0')) { inject = computedDecoratorWithParams( injectController, 'controller', "import { inject as controller } from '@ember/controller'" ); } else { inject = computedDecoratorWithParams( (desc, params) => { return injectController.apply(this, params); }, 'controller', "import { inject as controller } from '@ember/controller'" ); }

github glimmerjs / glimmer.js / packages / @glimmer / component / addon / -private / ember-component-manager.ts View on Github external
import { DEBUG } from '@glimmer/env';
import Ember from 'ember';
import { set } from '@ember/object';
import { getOwner, setOwner } from '@ember/application';
import { capabilities } from '@ember/component';
import { schedule } from '@ember/runloop';
import { gte } from 'ember-compatibility-helpers';
import BaseComponentManager, {
  ComponentManagerArgs,
  CustomComponentCapabilities,
} from './base-component-manager';

import GlimmerComponent, { setDestroyed, setDestroying } from './component';

const CAPABILITIES = gte('3.13.0-beta.1')
  ? capabilities('3.13', {
      destructor: true,
      asyncLifecycleCallbacks: false,
      updateHook: false,
    })
  : capabilities('3.4', {
      destructor: true,
      asyncLifecycleCallbacks: false,
    });

/**
 * This component manager runs in Ember.js environments and extends the base component manager to:
 *
 * 1. Properly destroy the component's associated `meta` data structure
 * 2. Schedule destruction using Ember's runloop
 */
github machty / ember-concurrency / addon / -task-group.js View on Github external
export const TaskGroup = EmberObject.extend(TaskStateMixin, {
  isTaskGroup: true,

  toString() {
    return ``;
  },

  _numRunningOrNumQueued: or('numRunning', 'numQueued'),
  isRunning: bool('_numRunningOrNumQueued'),
  isQueued: false,
});

export let TaskGroupProperty;

if (gte('3.10.0-alpha.1')) {
  TaskGroupProperty = class {};
} else {
  TaskGroupProperty = class extends _ComputedProperty {};
}

objectAssign(TaskGroupProperty.prototype, propertyModifiers);
github ember-decorators / ember-decorators / packages / utils / addon / computed.js View on Github external
import { DEBUG } from '@glimmer/env';
import { assert, deprecate } from '@ember/debug';
import ComputedProperty from '@ember/object/computed';

/**
 * A macro that receives a decorator function which returns a ComputedProperty,
 * and defines that property using `Ember.defineProperty`. Conceptually, CPs
 * are custom property descriptors that require Ember's intervention to apply
 * correctly. In the future, we will use finishers to define the CPs rather than
 * directly defining them in the decorator function.
 *
 * @param {Function} fn - decorator function
 */
export let computedDecorator;

if (gte('3.10.0')) {
  class ComputedDecoratorImpl extends Function {
    readOnly() {
      this.__computed.readOnly(...arguments);
      return this;
    }

    volatile() {
      this.__computed.volatile(...arguments);
      return this;
    }

    property() {
      this.__computed.property(...arguments);
      return this;
    }
github rwjblue / ember-modifier-manager-polyfill / vendor / ember-modifier-manager-polyfill.js View on Github external
runtimeResolver._lookupModifier = function(name, meta) {
            let builtin = this.builtInModifiers[name];

            if (builtin === undefined) {
              let { owner } = meta;
              let modifier = owner.factoryFor(`modifier:${name}`);
              if (modifier !== undefined) {
                let managerFactory = getModifierManager(modifier.class);
                let manager = managerFactory(owner);

                if (gte('3.6.0-alpha.1')) {
                  return new Polyfilled_CustomModifierDefinition(name, modifier, manager);
                } else {
                  return new Polyfilled_CustomModifierManagerLt36(name, modifier, manager);
                }
              }
            }

            return builtin;
          };
github rwjblue / ember-angle-bracket-invocation-polyfill / vendor / angle-bracket-invocation-polyfill / runtime-polyfill.js View on Github external
} else {
            references[name] = reference;
          }
        }
      }
    }
    if (classReferences.length > 1) {
      references['class'] = new ClassListReference(classReferences);
    } else if (classReferences.length > 0) {
      references['class'] = classReferences[0];
    }

    return new MergedAttributesReference(references);
  }

  if (gte('3.1.0-beta.1')) {
    Application.reopenClass({
      buildRegistry() {
        let registry = this._super(...arguments);

        let compilerName = gte('3.2.0-alpha.1')
          ? P`template-compiler:main`
          : P`template-options:main`;
        let TemplateCompiler = registry.resolve(compilerName);

        registry.register(
          'component-lookup:main',
          Ember.Object.extend({
            componentFor(name, owner, options) {
              let fullName = `component:${name}`;
              return owner.factoryFor(fullName, options);
            },
github emberjs / data / packages / model / addon / -private / util.ts View on Github external
export function computedMacroWithOptionalParams(fn) {
  if (gte('3.10.0')) {
    return (...maybeDesc: any[]) => (isElementDescriptor(maybeDesc) ? fn()(...maybeDesc) : fn(...maybeDesc));
  } else {
    return fn;
  }
}
github rwjblue / ember-modifier-manager-polyfill / vendor / ember-modifier-manager-polyfill.js View on Github external
environment.hasModifier = function(name, metaOrSymbolTable) {
            let owner = gte('2.15.0-alpha.1')
              ? metaOrSymbolTable.owner
              : metaOrSymbolTable.getMeta().owner;

            return !!this.builtInModifiers[name] || !!owner.hasRegistration(`modifier:${name}`);
          };

ember-compatibility-helpers

Zero-cost compatibility flags and helpers for Ember.js

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis

Popular ember-compatibility-helpers functions