本文整理匯總了TypeScript中@ember/-internals/meta.meta函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript meta函數的具體用法?TypeScript meta怎麽用?TypeScript meta使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了meta函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: get
get(obj: object, keyName: string) {
let ret = get(obj, this.altKey);
let cache = getCacheFor(obj);
if (cache.get(keyName) !== CONSUMED) {
let meta = metaFor(obj);
cache.set(keyName, CONSUMED);
addDependentKeys(this, obj, keyName, meta);
}
return ret;
}
示例2: watchPath
export function watchPath(obj: any, keyPath: string, meta?: Meta): void {
let m = meta === undefined ? metaFor(obj) : meta;
let counter = m.peekWatching(keyPath);
m.writeWatching(keyPath, counter + 1);
if (counter === 0) {
// activate watching first time
m.writableChains(makeChainNode).add(keyPath);
}
}
示例3: tagFor
export function tagFor(object: any | null, _meta?: Meta): Tag {
if (typeof object === 'object' && object !== null) {
let meta = _meta === undefined ? metaFor(object) : _meta;
if (!meta.isMetaDestroyed()) {
return meta.writableTag(makeTag);
}
}
return CONSTANT_TAG;
}
示例4: applyMixin
export function applyMixin(obj: { [key: string]: any }, mixins: Mixin[]) {
let descs = {};
let values = {};
let meta = metaFor(obj);
let keys: string[] = [];
let key, value, desc;
(obj as any)._super = ROOT;
// Go through all mixins and hashes passed in, and:
//
// * Handle concatenated properties
// * Handle merged properties
// * Set up _super wrapping if necessary
// * Set up computed property descriptors
// * Copying `toString` in broken browsers
mergeMixins(mixins, meta, descs, values, obj, keys);
for (let i = 0; i < keys.length; i++) {
key = keys[i];
if (key === 'constructor' || !values.hasOwnProperty(key)) {
continue;
}
desc = descs[key];
value = values[key];
if (ALIAS_METHOD) {
while (value && value instanceof AliasImpl) {
let followed = followMethodAlias(obj, value, descs, values);
desc = followed.desc;
value = followed.value;
}
}
if (desc === undefined && value === undefined) {
continue;
}
if (descriptorForProperty(obj, key) !== undefined) {
replaceObserversAndListeners(obj, key, null, value);
} else {
replaceObserversAndListeners(obj, key, obj[key], value);
}
defineProperty(obj, key, desc, value, meta);
}
return obj;
}
示例5: removeListener
export function removeListener(
obj: object,
eventName: string,
target: object | null,
method?: Function | string
) {
assert('You must pass at least an object and event name to removeListener', !!obj && !!eventName);
if (!method && 'function' === typeof target) {
method = target;
target = null;
}
metaFor(obj).removeFromListeners(eventName, target, method!);
}
示例6: addListener
export function addListener(
obj: object,
eventName: string,
target: object | Function | null,
method?: Function | string,
once?: boolean
) {
assert('You must pass at least an object and event name to addListener', !!obj && !!eventName);
if (!method && 'function' === typeof target) {
method = target;
target = null;
}
metaFor(obj).addToListeners(eventName, target, method!, once === true);
}
示例7: removeListener
export function removeListener(
obj: object,
eventName: string,
target: object | null,
method?: Function | string
): void {
assert('You must pass at least an object and event name to removeListener', !!obj && !!eventName);
if (!method && 'function' === typeof target) {
method = target;
target = null;
}
let m = metaFor(obj);
if (method === undefined) {
m.removeAllListeners(eventName);
} else {
m.removeFromListeners(eventName, target, method);
}
}
示例8: tagForProperty
export function tagForProperty(object: any, propertyKey: string | symbol, _meta?: Meta): Tag {
if (typeof object !== 'object' || object === null) {
return CONSTANT_TAG;
}
let meta = _meta === undefined ? metaFor(object) : _meta;
if (isProxy(object)) {
return tagFor(object, meta);
}
let tags = meta.writableTags();
let tag = tags[propertyKey];
if (tag) {
return tag;
}
if (EMBER_METAL_TRACKED_PROPERTIES) {
let pair = combine([makeTag(), UpdatableTag.create(CONSTANT_TAG)]);
return (tags[propertyKey] = pair);
} else {
return (tags[propertyKey] = makeTag());
}
}
示例9: watchKey
export function watchKey(obj: object, keyName: string, _meta?: Meta): void {
let meta = _meta === undefined ? metaFor(obj) : _meta;
let count = meta.peekWatching(keyName);
meta.writeWatching(keyName, count + 1);
if (count === 0) {
// activate watching first time
let possibleDesc = descriptorForProperty(obj, keyName, meta);
if (possibleDesc !== undefined && possibleDesc.willWatch !== undefined) {
possibleDesc.willWatch(obj, keyName, meta);
}
if (typeof (obj as MaybeHasWillWatchProperty).willWatchProperty === 'function') {
(obj as MaybeHasWillWatchProperty).willWatchProperty!(keyName);
}
if (DEBUG) {
// NOTE: this is dropped for prod + minified builds
handleMandatorySetter(meta, obj, keyName);
}
}
}
示例10: markObjectAsDirty
export function markObjectAsDirty(obj: object, propertyKey: string, _meta?: Meta): void {
let meta = _meta === undefined ? metaFor(obj) : _meta;
let objectTag = meta.readableTag();
if (objectTag !== undefined) {
if (isProxy(obj)) {
(objectTag.inner! as any).first.inner.dirty();
} else {
(objectTag.inner! as any).dirty();
}
}
let tags = meta.readableTags();
let propertyTag = tags !== undefined ? tags[propertyKey] : undefined;
if (propertyTag !== undefined) {
dirty(propertyTag);
}
if (objectTag !== undefined || propertyTag !== undefined) {
ensureRunloop();
}
}