當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Map.set函數代碼示例

本文整理匯總了TypeScript中dojo-shim/Map.set函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript set函數的具體用法?TypeScript set怎麽用?TypeScript set使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了set函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

		initialize: function(instance: TrackableSubCollection<T, O, U, C>, options?: TrackableOptions<T>) {
			options = options || {};
			instanceStateMap.set(instance, {
				isTracking: Boolean(options.isTracking),
				sourceQuery: options.sourceQuery,
				localData: [],
				idToIndex: new Map<string, number>(),
				observers: [],
				toRemoveIndices: []
			});

			if (options.isTracking && instance.source) {
				const state = instanceStateMap.get(instance);
				instance.fetch().then(function(data) {
					state.localData = data;
					instance.identify(data).forEach(function(id, index) {
						state.idToIndex.set(id, index);
					});
				});

				state.observable = new Observable<TrackedStoreDelta<T>>(function(observer: Observer<TrackedStoreDelta<T>>) {
					state.observers.push(observer);
					return () => {
						return state.toRemoveIndices.push(state.observers.indexOf(observer));
					};
				}.bind(instance));

				instance.source.observe().subscribe(buildTrackedUpdate(state, instance));
			}
		},
開發者ID:maier49,項目名稱:store,代碼行數:30,代碼來源:createTrackableMixin.ts

示例2: get

interface TodoRegistryOptions {
	widgetStore: MemoryStore<Object>;
}

interface TodoRegistry {
	get(id: string): Promise<TodoItem>;
	identify(value: TodoItem): string;
	widgetStore?: MemoryStore<Object>;
}

const todoRegistryFactory = compose({
	get(id: string): Promise<TodoItem> {
		let widget: TodoItem = idToWidgetMap.get(id);
		if (!widget) {
			widget = createTodoItem({id, stateFrom: this.widgetStore});
			widgetToIdMap.set(widget, id);
			idToWidgetMap.set(id, widget);
		}
		return Promise.resolve(widget);
	},
	identify(value: TodoItem): string {
		return widgetToIdMap.get(value);
	}
}, function (todoRegistry: TodoRegistry, options: TodoRegistryOptions) {
	if (options) {
		todoRegistry.widgetStore = options.widgetStore;
	}
});

export default todoRegistryFactory;
開發者ID:Tomdye,項目名稱:dojo2-todo-mvc,代碼行數:30,代碼來源:createTodoRegistry.ts

示例3: stackSelector

							{ originalPoints: [], columns: [], isNegative: true, relativeValue: 0, value: 0 },
							{ originalPoints: [], columns: [], isNegative: false, relativeValue: 0, value: 0 }
						];
					};

					for (const point of originalPoints) {
						const { datum } = point;
						const { input, relativeValue, value } = datum;

						// Note that the ordering of the stacks is determined by the original sort order, as is the
						// ordering of nodes within the stack.
						const stack = stackSelector(input);
						const signed = stacks.get(stack) || createSigned();
						const record = relativeValue < 0 ? signed[0] : signed[1];
						if (!stacks.has(stack)) {
							stacks.set(stack, signed);
						}

						record.originalPoints.push(point);
						record.columns.push(datum);
						record.relativeValue += relativeValue;
						record.value += value;

						if (record.relativeValue < mostNegativeRelValue) {
							mostNegativeRelValue = record.relativeValue;
						}
						else if (record.relativeValue > mostPositiveRelValue) {
							mostPositiveRelValue = record.relativeValue;
						}

						if (record.value < mostNegativeValue) {
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:31,代碼來源:createStackedColumnChart.ts

示例4:

			store.identify(newData).forEach(function(id, index) {
				newIndex.set(id, index);
			});
開發者ID:maier49,項目名稱:store,代碼行數:3,代碼來源:createTrackableMixin.ts

示例5: groupSelector

						y1: number;
					}
					const groups = new Map<G, Record>();
					const createRecord = (): Record => {
						return { originalPoints: [], columns: [], totalValue: 0, value: 0, y1: columnHeight };
					};

					for (const point of originalPoints) {
						const { input, relativeValue, value } = point.datum;

						// Note that the ordering of the groups is determined by the original sort order, as is the
						// ordering of nodes within the group.
						const group = groupSelector(input);
						const record = groups.get(group) || createRecord();
						if (!groups.has(group)) {
							groups.set(group, record);
						}

						record.originalPoints.push(point);
						record.columns.push(point.datum);
						record.totalValue += value;
						if (relativeValue < 0) {
							record.value = Math.min(record.value, value);
						}
						else {
							// Note that the expected value for mixed groups is undefined.
							record.value = Math.max(record.value, value);
						}
						record.y1 = Math.min(record.y1, point.y1);
					}
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:30,代碼來源:createGroupedColumnChart.ts


注:本文中的dojo-shim/Map.set函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。