本文整理汇总了TypeScript中Immutable.OrderedMap类的典型用法代码示例。如果您正苦于以下问题:TypeScript OrderedMap类的具体用法?TypeScript OrderedMap怎么用?TypeScript OrderedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrderedMap类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it ('Add several custom fields', () => {
const state: CustomFieldState = getTestCustomFieldState();
customFieldMetaReducer(initialCustomFieldState, CustomFieldActions.createDeserializeCustomFields(getTestCustomFieldsInput()));
const newState: CustomFieldState =
customFieldMetaReducer(state, CustomFieldActions.createAddCustomFields({
'Custom-1': [{key: 'c1-a', value: 'A'}, {key: 'c1-z', value: 'Z'}],
'Custom-2': [{key: 'c2-k', value: 'k'}]}));
const map: OrderedMap<string, List<CustomField>> = newState.fields.map(value => value.toList()).toOrderedMap();
expect(map.size).toBe(2);
const l1 = map.get('Custom-1');
expect(l1.size).toBe(5);
expect(l1.get(0).key).toEqual('c1-a');
expect(l1.get(0).value).toEqual('A');
expect(l1.get(1).key).toEqual('c1-A');
expect(l1.get(1).value).toEqual('First C1');
expect(l1.get(2).key).toEqual('c1-B');
expect(l1.get(2).value).toEqual('Second C1');
expect(l1.get(3).key).toEqual('c1-C');
expect(l1.get(3).value).toEqual('Third C1');
expect(l1.get(4).key).toEqual('c1-z');
expect(l1.get(4).value).toEqual('Z');
const l2 = map.get('Custom-2');
expect(l2.size).toBe(3);
expect(l2.get(0).key).toEqual('c2-A');
expect(l2.get(0).value).toEqual('First C2');
expect(l2.get(1).key).toEqual('c2-k');
expect(l2.get(1).value).toEqual('k');
expect(l2.get(2).key).toEqual('c2-B');
expect(l2.get(2).value).toEqual('Second C2');
});
示例2: updateArmies
public updateArmies(armies:OrderedMap<number, Army>) {
if (!armies||!armies.forEach) {
return;
}
this.armies = armies;
if (!this.terrain||!this.terrain.initialized) {
return;
}
if (this.armyMeshes) {
this.armyMeshes.forEach((armyMesh) => {
this.scene.remove(armyMesh);
this.meshFactory.disposeMesh(armyMesh);
});
}
this.armyMeshes = [];
this.armies.forEach((army) => {
let armyMesh:Mesh = this.meshFactory.createArmyMesh(army, this.getDisplayPosition(army.pos));
this.armyMeshes.push(armyMesh);
this.scene.add(armyMesh);
})
}
示例3: updateMovements
public updateMovements(movements:OrderedMap<number, List<Movement>>) {
if (!movements||!movements.forEach) {
return;
}
this.movements = movements;
if (!this.terrain||!this.terrain.initialized) {
return;
}
if (this.movementMeshes) {
this.movementMeshes.forEach((movementMesh) => {
this.scene.remove(movementMesh);
this.meshFactory.disposeMesh(movementMesh);
});
}
this.movementMeshes = [];
this.movements.forEach((movementList) => {
movementList.forEach((movement) => {
let movementMesh:Mesh = this.meshFactory.createMovementMesh(movement, this.getDisplayPosition(movement.from), this.getDisplayPosition(movement.to));
this.movementMeshes.push(movementMesh);
this.scene.add(movementMesh);
})
})
}
示例4: Seq
const updateEntities = (entities: OrderedMap<string, Item>, items: Item[]): OrderedMap<string, Item> => {
return entities.withMutations(map => {
Seq(items).forEach(item => map.set(item._id, item))
});
};
示例5: geoReducer
function geoReducer(
soFar: OrderedMap<string, Geo>,
{ geoid, name, points },
): OrderedMap<string, Geo> {
return soFar.set(geoid, new Geo(name, points.northeast, points.southwest));
}
示例6:
(soFar: OrderedMap<string, MapKeyColor[]>, layer) => {
if (layer.metadata && layer.metadata.keyColors) {
return soFar.set(layer.id, layer.metadata.keyColors);
}
return soFar;
},
示例7: switch
export const itemReducer: ActionReducer<any> = (state = initialState, action: ItemActions): ItemsState => {
switch (action.type) {
case ItemActionTypes.ITEMS_LOADED: {
const items = updateEntities(state.items, action.payload);
return Object.assign({}, state, {items});
}
case ItemActionTypes.TRANSCODE_PROGRESS: {
const progress = action.payload;
const transcode = state.transcode.set(progress._id, progress);
return Object.assign({}, state, {transcode})
}
case ItemActionTypes.FILTER_ITEMS: {
return Object.assign({}, state, {itemFilter: action.payload})
}
case ItemActionTypes.ITEM_SEARCH: {
return Object.assign({}, state, {searchFilter: action.payload})
}
default:
return state;
}
};