本文整理汇总了TypeScript中@dojo/shim/WeakMap.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeProperties
beforeProperties(function(this: WidgetBase & { own: Function }, properties: any) {
const injectorItem = this.registry.getInjector<Store<S>>(name);
if (injectorItem) {
const { injector } = injectorItem;
const store = injector();
const registeredInjectors = registeredInjectorsMap.get(this) || [];
if (registeredInjectors.length === 0) {
registeredInjectorsMap.set(this, registeredInjectors);
}
if (registeredInjectors.indexOf(injectorItem) === -1) {
if (paths) {
const handle = store.onChange(paths.map((path: any) => store.path(path.join('/'))), () =>
this.invalidate()
);
this.own({
destroy: () => {
handle.remove();
}
});
} else {
this.own(
store.on('invalidate', () => {
this.invalidate();
})
);
}
registeredInjectors.push(injectorItem);
}
return getProperties(store, properties);
}
})(target);
示例2: Error
const append = (route: Route<Context, Parameters>) => {
if (hasBeenAppended(route)) {
throw new Error('Cannot append route that has already been appended');
}
this._routes.push(route);
parentMap.set(route, this);
};
示例3: constructor
constructor(source?: Iterable<T> | ArrayLike<T>) {
listItems.set(this, []);
if (source) {
forOf(source, (item: T) => {
this.add(item);
});
}
}
示例4: constructor
constructor(source?: Iterable<T> | ArrayLike<T>) {
listItems.set(this, []);
if (source) {
if (isArrayLike(source)) {
for (let i = 0; i < source.length; i++) {
this.add(source[i]);
}
} else if (isIterable(source)) {
for (const item of source) {
this.add(item);
}
}
}
}
示例5: configure
}
},
configure(this: AnyAction, configuration: Object): Promise<void> | void {
const configureFn = configureFunctions.get(this);
if (configureFn) {
return configureFn.call(this, configuration);
}
}
})
.mixin({
mixin: createStateful,
initialize(instance: AnyAction, { do: doFn, enabled = true, configure }: ActionOptions<any, ActionState>) {
if (!doFn) {
throw new TypeError(`'options.do' required during creation.`);
}
doFunctions.set(instance, doFn);
instance.setState({ enabled });
if (configure) {
configureFunctions.set(instance, configure);
}
instance.own({
destroy() {
doFunctions.delete(instance);
configureFunctions.delete(instance);
}
});
}
});
export default createAction;
示例7: constructor
constructor() {
privateStateMap.set(this, {
entryMap: new Map<Identity, Entry<V>>(),
idMap: new WeakMap<V, Identity>()
});
}
示例8:
.init((instance) => {
handlesWeakMap.set(instance, []);
});
示例9:
.init((instance: Stateful<State>) => {
instanceStateMap.set(instance, Object.create(null));
});
示例10: state
/**
* State change event type
*/
const stateChangedEventType = 'state:changed';
/**
* Create an instance of a stateful object
*/
const statefulMixin: StatefulMixin = eventedMixin
.extend('Stateful', {
get state(this: Stateful<State>) {
return instanceStateMap.get(this);
},
setState<S extends State>(this: Stateful<S>, value: Partial<S>) {
const oldState = instanceStateMap.get(this);
const state = deepAssign({}, oldState, value);
const eventObject = {
type: stateChangedEventType,
state,
target: this
};
instanceStateMap.set(this, state);
this.emit(eventObject);
}
})
.init((instance: Stateful<State>) => {
instanceStateMap.set(instance, Object.create(null));
});
export default statefulMixin;