本文整理匯總了TypeScript中ember-utils.symbol函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript symbol函數的具體用法?TypeScript symbol怎麽用?TypeScript symbol使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了symbol函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: create
normalizedName?: string;
create(props?: { [prop: string]: any }): T;
}
export interface Owner {
lookup<T>(fullName: string, options?: LookupOptions): T;
lookup(fullName: string, options?: LookupOptions): any;
factoryFor<T, C>(fullName: string, options?: LookupOptions): Factory<T, C> | undefined;
factoryFor(fullName: string, options?: LookupOptions): Factory<any, any> | undefined;
buildChildEngineInstance<T>(name: string): T;
hasRegistration(name: string, options?: LookupOptions): boolean;
}
import { symbol } from 'ember-utils';
export const OWNER = symbol('OWNER');
/**
Framework objects in an Ember application (components, services, routes, etc.)
are created via a factory and dependency injection system. Each of these
objects is the responsibility of an "owner", which handled its
instantiation and manages its lifetime.
`getOwner` fetches the owner object responsible for an instance. This can
be used to lookup or resolve other class instances, or register new factories
into the owner.
For example, this component dynamically looks up a service based on the
`audioType` passed as an attribute:
```app/components/play-audio.js
示例2: symbol
import { ComponentManager } from '@glimmer/runtime';
import { assert } from 'ember-debug';
import { Owner, symbol } from 'ember-utils';
import DefinitionState from '../component-managers/definition-state';
import ComponentStateBucket from '../utils/curly-component-state-bucket';
import { GLIMMER_CUSTOM_COMPONENT_MANAGER } from 'ember/features';
export const COMPONENT_MANAGER = symbol('COMPONENT_MANAGER');
export function componentManager(obj: any, managerId: String) {
if ('reopenClass' in obj) {
return obj.reopenClass({
[COMPONENT_MANAGER]: managerId
});
}
obj[COMPONENT_MANAGER] = managerId;
return obj;
}
export default function getCustomComponentManager(owner: Owner, obj: {}): ComponentManager<ComponentStateBucket, DefinitionState> | undefined {
if (!GLIMMER_CUSTOM_COMPONENT_MANAGER) { return; }
if (!obj) { return; }
let managerId = obj[COMPONENT_MANAGER];
if (!managerId) { return; }
示例3: symbol
PROPERTY_DID_CHANGE,
} from 'ember-metal';
import { TargetActionSupport } from 'ember-runtime';
import { getOwner, NAME_KEY, symbol } from 'ember-utils';
import {
ActionSupport,
ChildViewsSupport,
ClassNamesSupport,
CoreView,
getViewElement,
ViewMixin,
ViewStateSupport,
} from 'ember-views';
import { RootReference, UPDATE } from './utils/references';
export const DIRTY_TAG = symbol('DIRTY_TAG');
export const ARGS = symbol('ARGS');
export const ROOT_REF = symbol('ROOT_REF');
export const IS_DISPATCHING_ATTRS = symbol('IS_DISPATCHING_ATTRS');
export const HAS_BLOCK = symbol('HAS_BLOCK');
export const BOUNDS = symbol('BOUNDS');
/**
@module @ember/component
*/
/**
A `Component` is a view that is completely
isolated. Properties accessed in its templates go
to the view object and actions are targeted at
the view object. There is no access to the
示例4: symbol
if (DEBUG) {
counters = {
peekCalls: 0,
peekPrototypeWalks: 0,
setCalls: 0,
deleteCalls: 0,
metaCalls: 0,
metaInstantiated: 0,
};
}
/**
@module ember
*/
export const UNDEFINED = symbol('undefined');
// FLAGS
const SOURCE_DESTROYING = 1 << 1;
const SOURCE_DESTROYED = 1 << 2;
const META_DESTROYED = 1 << 3;
export class Meta {
_descriptors: any | undefined;
_watching: any | undefined;
_mixins: any | undefined;
_deps: any | undefined;
_chainWatchers: any | undefined;
_chains: any | undefined;
_tag: Tag | undefined;
_tags: any | undefined;
示例5: symbol
} from 'ember-metal';
import {
symbol,
} from 'ember-utils';
import {
EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER,
MANDATORY_SETTER,
} from 'ember/features';
import {
HelperFunction,
HelperInstance,
RECOMPUTE_TAG,
} from '../helper';
import emberToBool from './to-bool';
export const UPDATE = symbol('UPDATE');
export const INVOKE = symbol('INVOKE');
export const ACTION = symbol('ACTION');
let maybeFreeze: (obj: any) => void;
if (DEBUG) {
// gaurding this in a DEBUG gaurd (as well as all invocations)
// so that it is properly stripped during the minification's
// dead code elimination
maybeFreeze = (obj: any) => {
// re-freezing an already frozen object introduces a significant
// performance penalty on Chrome (tested through 59).
//
// See: https://bugs.chromium.org/p/v8/issues/detail?id=6450
if (!Object.isFrozen(obj)) {
Object.freeze(obj);
示例6: symbol
watchKey,
} from 'ember-metal';
import {
symbol,
} from 'ember-utils';
import {
EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER,
MANDATORY_SETTER,
} from 'ember/features';
import {
RECOMPUTE_TAG,
SimpleHelper,
} from '../helper';
import emberToBool from './to-bool';
export const UPDATE = symbol('UPDATE');
let maybeFreeze: (obj: any) => void;
if (DEBUG) {
// gaurding this in a DEBUG gaurd (as well as all invocations)
// so that it is properly stripped during the minification's
// dead code elimination
maybeFreeze = (obj: any) => {
// re-freezing an already frozen object introduces a significant
// performance penalty on Chrome (tested through 59).
//
// See: https://bugs.chromium.org/p/v8/issues/detail?id=6450
if (!Object.isFrozen(obj)) {
Object.freeze(obj);
}
};
示例7: symbol
Increment count
</button>
```
You can also use the `value` option:
```handlebars
<input value={{name}} oninput={{action (mut name) value="target.value"}}>
```
@method mut
@param {Object} [attr] the "two-way" attribute that can be modified.
@for Ember.Templates.helpers
@public
*/
const MUT_REFERENCE = symbol('MUT');
const SOURCE = symbol('SOURCE');
export function isMut(ref: any): boolean {
return ref && ref[MUT_REFERENCE];
}
export function unMut(ref: any) {
return ref[SOURCE] || ref;
}
export default function(_vm: VM, args: Arguments) {
let rawRef = args.positional.at(0);
if (isMut(rawRef)) {
return rawRef;
示例8: symbol
} from '@ember/deprecated-features';
import { DEBUG } from '@glimmer/env';
import { descriptorFor, Meta, peekMeta } from 'ember-meta';
import { symbol } from 'ember-utils';
import changeEvent from './change_event';
import { sendEvent } from './events';
import ObserverSet from './observer_set';
import { markObjectAsDirty } from './tags';
import { assertNotRendered } from './transaction';
/**
@module ember
@private
*/
export const PROPERTY_DID_CHANGE = symbol('PROPERTY_DID_CHANGE');
const observerSet = new ObserverSet();
let deferred = 0;
// ..........................................................
// PROPERTY CHANGES
//
/**
@method propertyWillChange
@for Ember
@private
*/
let propertyWillChange;
if (ENABLE_PROPERTY_WILL_CHANGE) {
示例9: if
if (typeof value === 'function' && value[ACTION]) {
attrs[name] = value;
} else if (ref[UPDATE]) {
attrs[name] = new MutableCell(ref, value);
}
args[name] = ref;
props[name] = value;
}
props.attrs = attrs;
return props;
}
const REF = symbol('REF');
class MutableCell {
public value: any;
constructor(ref: any, value: any) {
this[MUTABLE_CELL] = true;
this[REF] = ref;
this.value = value;
}
update(val: any) {
this[REF][UPDATE](val);
}
}
示例10: symbol
```handlebars
<ul>
{{#each-in user as |key value|}}
<li>{{key}}: {{value}}</li>
{{/each-in}}
</ul>
```
Outputting their name and age.
@method each-in
@for Ember.Templates.helpers
@public
@since 2.1.0
*/
const EACH_IN_REFERENCE = symbol('EACH_IN');
class EachInReference implements VersionedPathReference {
public tag: Tag;
constructor(private inner: VersionedPathReference) {
this.tag = inner.tag;
this[EACH_IN_REFERENCE] = true;
}
value(): Opaque {
return this.inner.value();
}
get(key: string): VersionedPathReference {
return this.inner.get(key);