本文整理汇总了TypeScript中ember-meta.Meta类的典型用法代码示例。如果您正苦于以下问题:TypeScript Meta类的具体用法?TypeScript Meta怎么用?TypeScript Meta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Meta类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
function mixinProperties<T extends MixinLike>(mixinsMeta: Meta, mixin: T): MixinLike {
if (mixin instanceof Mixin) {
if (mixinsMeta.hasMixin(mixin)) {
return CONTINUE;
}
mixinsMeta.addMixin(mixin);
return mixin.properties!;
} else {
return mixin; // apply anonymous mixin properties
}
}
示例2: finishChains
function finishChains(meta: Meta): void {
// finish any current chains node watchers that reference obj
let chainWatchers = meta.readableChainWatchers();
if (chainWatchers !== undefined) {
chainWatchers.revalidateAll();
}
// ensure that if we have inherited any chains they have been
// copied onto our own meta.
if (meta.readableChains() !== undefined) {
meta.writableChains(makeChainNode);
}
}
示例3: iterDeps
function iterDeps(
method: (obj: object, key: string, meta: Meta) => void,
obj: object,
depKey: string,
seen: Map<object, Set<string>>,
meta: Meta
) {
let current = seen.get(obj);
if (current === undefined) {
current = new Set();
seen.set(obj, current);
}
if (current.has(depKey)) {
return;
}
let possibleDesc;
meta.forEachInDeps(depKey, (key: string) => {
possibleDesc = descriptorFor(obj, key, meta);
if (possibleDesc !== undefined && possibleDesc._suspended === obj) {
return;
}
method(obj, key, meta);
});
}
示例4: notifyObservers
function notifyObservers(obj: object, keyName: string, meta: Meta) {
if (meta.isSourceDestroying()) {
return;
}
let eventName = changeEvent(keyName);
if (deferred > 0) {
observerSet.add(obj, keyName, eventName);
} else {
sendEvent(obj, eventName, [obj, keyName]);
}
}
示例5: markObjectAsDirty
export function markObjectAsDirty(obj: object, propertyKey: string, meta: Meta): void {
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();
}
}
示例6: dependentKeysDidChange
// called whenever a property has just changed to update dependent keys
function dependentKeysDidChange(obj: object, depKey: string, meta: Meta) {
if (meta.isSourceDestroying() || !meta.hasDeps(depKey)) {
return;
}
let seen = SEEN_MAP;
let isTop = IS_TOP_SEEN_MAP;
if (isTop) {
IS_TOP_SEEN_MAP = false;
}
iterDeps(notifyPropertyChange, obj, depKey, seen, meta);
if (isTop) {
SEEN_MAP.clear();
IS_TOP_SEEN_MAP = true;
}
}
示例7: removeDependentKeys
export function removeDependentKeys(
desc: DescriptorWithDependentKeys,
obj: object,
keyName: string,
meta: Meta
): void {
// the descriptor has a list of dependent keys, so
// remove all of its dependent keys.
let depKeys = desc._dependentKeys;
if (depKeys === null || depKeys === undefined) {
return;
}
for (let idx = 0; idx < depKeys.length; idx++) {
let depKey = depKeys[idx];
// Decrement the number of times depKey depends on keyName.
meta.writeDeps(depKey, keyName, meta.peekDeps(depKey, keyName) - 1);
// Unwatch the depKey
unwatch(obj, depKey, meta);
}
}
示例8: defineProperty
export function defineProperty(
obj: object,
keyName: string,
desc: Descriptor | undefined | null,
data?: any | undefined | null,
meta?: Meta
) {
if (meta === undefined) {
meta = metaFor(obj);
}
let watching = meta.peekWatching(keyName) > 0;
let previousDesc = descriptorFor(obj, keyName, meta);
let wasDescriptor = previousDesc !== undefined;
if (wasDescriptor) {
previousDesc.teardown(obj, keyName, meta);
meta.removeDescriptors(keyName);
}
// used to track if the the property being defined be enumerable
let enumerable = true;
// Ember.NativeArray is a normal Ember.Mixin that we mix into `Array.prototype` when prototype extensions are enabled
// mutating a native object prototype like this should _not_ result in enumerable properties being added (or we have significant
// issues with things like deep equality checks from test frameworks, or things like jQuery.extend(true, [], [])).
//
// this is a hack, and we should stop mutating the array prototype by default 😫
if (obj === Array.prototype) {
enumerable = false;
}
let value;
if (desc instanceof Descriptor) {
value = desc;
Object.defineProperty(obj, keyName, {
configurable: true,
enumerable,
get: DESCRIPTOR_GETTER_FUNCTION(keyName, value),
});
meta.writeDescriptors(keyName, value);
desc.setup(obj, keyName);
} else if (desc === undefined || desc === null) {
value = data;
if (DEBUG && watching) {
meta.writeValues(keyName, data);
let defaultDescriptor = {
configurable: true,
enumerable,
set: MANDATORY_SETTER_FUNCTION(keyName),
get: DEFAULT_GETTER_FUNCTION(keyName),
};
Object.defineProperty(obj, keyName, defaultDescriptor);
} else if (wasDescriptor || enumerable === false) {
Object.defineProperty(obj, keyName, {
configurable: true,
enumerable,
writable: true,
value,
});
} else {
obj[keyName] = data;
}
} else {
value = desc;
// fallback to ES5
Object.defineProperty(obj, keyName, desc);
}
// if key is being watched, override chains that
// were initialized with the prototype
if (watching) {
overrideChains(obj, keyName, meta);
}
// The `value` passed to the `didDefineProperty` hook is
// either the descriptor or data, whichever was passed.
if (typeof (obj as ExtendedObject).didDefineProperty === 'function') {
(obj as ExtendedObject).didDefineProperty!(obj, keyName, value);
}
}
示例9: overrideChains
function overrideChains(_obj: object, keyName: string, meta: Meta) {
let chainWatchers = meta.readableChainWatchers();
if (chainWatchers !== undefined) {
chainWatchers.revalidate(keyName);
}
}
示例10: chainsDidChange
function chainsDidChange(_obj: object, keyName: string, meta: Meta) {
let chainWatchers = meta.readableChainWatchers();
if (chainWatchers !== undefined) {
chainWatchers.notify(keyName, true, notifyPropertyChange);
}
}