当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Store.dispatch方法代码示例

本文整理汇总了TypeScript中app/store.Store.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.dispatch方法的具体用法?TypeScript Store.dispatch怎么用?TypeScript Store.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app/store.Store的用法示例。


在下文中一共展示了Store.dispatch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: onSuccess

 private onSuccess(
   importType: ImportType,
   resetWorkspace: boolean,
   vls: ReadonlyArray<VectorLayer>,
   animation?: Animation,
   hiddenLayerIds?: ReadonlySet<string>,
 ) {
   if (importType === ImportType.Json) {
     ga('send', 'event', 'Import', 'JSON');
     this.store.dispatch(new ResetWorkspace(vls[0], animation, hiddenLayerIds));
   } else {
     if (importType === ImportType.Svg) {
       ga('send', 'event', 'Import', 'SVG');
     } else if (importType === ImportType.VectorDrawable) {
       ga('send', 'event', 'Import', 'Vector Drawable');
     }
     if (resetWorkspace) {
       this.store.dispatch(new ResetWorkspace());
     }
     this.layerTimelineService.importLayers(vls);
     // TODO: count number of individual layers?
     this.snackBarService.show(
       `Imported ${vls.length} layer${vls.length === 1 ? '' : 's'}`,
       'Dismiss',
       Duration.Short,
     );
   }
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:28,代码来源:fileimport.service.ts

示例2: swapLayers

 /**
  * Replaces an existing layer in the tree with a new layer. Note that
  * this method assumes that both layers still have the same children layers.
  */
 swapLayers(layerId: string, newLayer: Layer) {
   if (layerId === newLayer.id) {
     this.updateLayer(newLayer);
     return;
   }
   const vl = this.getVectorLayer();
   const parent = LayerUtil.findParent(vl, layerId).clone();
   const layerIndex = _.findIndex(parent.children, l => l.id === layerId);
   const children = [...parent.children];
   children.splice(layerIndex, 1, newLayer);
   parent.children = children;
   const actions: Action[] = [
     new SetVectorLayer(LayerUtil.updateLayer(vl, parent)),
     ...this.buildCleanupLayerIdActions(layerId),
   ];
   const animation = this.getAnimation();
   const oldLayerBlocks = animation.blocks.filter(b => b.layerId === layerId);
   const newAnimatableProperties = new Set(newLayer.animatableProperties.keys());
   // Preserve any blocks that are still animatable with the new layer.
   const newLayerBlocks = oldLayerBlocks
     .filter(b => newAnimatableProperties.has(b.propertyName))
     .map(b => {
       b = b.clone();
       b.layerId = newLayer.id;
       return b;
     });
   const newAnimation = animation.clone();
   newAnimation.blocks = [
     ...animation.blocks.filter(b => b.layerId !== layerId),
     ...newLayerBlocks,
   ];
   actions.push(new SetAnimation(newAnimation));
   this.store.dispatch(new BatchAction(...actions));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:38,代码来源:layertimeline.service.ts

示例3: toggleSubPathSelection

 toggleSubPathSelection(source: ActionSource, subIdx: number) {
   const selections = [...this.getSelections()];
   _.remove(selections, s => s.type !== SelectionType.SubPath || s.source !== source);
   const type = SelectionType.SubPath;
   const toggledSelections = this.toggleSelections(selections, [{ type, source, subIdx }]);
   this.store.dispatch(new SetActionModeSelections(toggledSelections));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:7,代码来源:actionmode.service.ts

示例4: closeActionMode

 closeActionMode() {
   const mode = this.getActionMode();
   if (mode === ActionMode.None) {
     return;
   }
   if (mode === ActionMode.Selection) {
     if (this.queryStore(getActionModeSelections).length) {
       // TODO: move this logic out into a component (it's confusing)
       this.store.dispatch(new SetActionModeSelections([]));
     } else {
       this.store.dispatch(new SetActionMode(ActionMode.None));
     }
   } else {
     this.store.dispatch(new SetActionMode(ActionMode.Selection));
   }
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:16,代码来源:actionmode.service.ts

示例5: shiftPointToFront

 shiftPointToFront() {
   const selections = this.getSelections().filter(s => s.type === SelectionType.Point);
   const { source, subIdx, cmdIdx } = selections[0];
   const activePath = this.getActivePathBlockValue(source);
   const pm = activePath.mutate();
   pm.shiftSubPathForward(subIdx, cmdIdx);
   this.store.dispatch(this.buildUpdatedActivePathBlockAnimationAction(source, pm.build()));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:8,代码来源:actionmode.service.ts

示例6: toggleVisibleLayer

 /**
  * Toggles the specified layer's visibility.
  */
 toggleVisibleLayer(layerId: string) {
   const layerIds = this.getHiddenLayerIds();
   if (layerIds.has(layerId)) {
     layerIds.delete(layerId);
   } else {
     layerIds.add(layerId);
   }
   this.store.dispatch(new SetHiddenLayers(layerIds));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:12,代码来源:layertimeline.service.ts

示例7: autoFix

 autoFix() {
   const [from, to] = AutoAwesome.autoFix(
     this.getActivePathBlockValue(ActionSource.From),
     this.getActivePathBlockValue(ActionSource.To),
   );
   let animation = this.buildUpdatedActivePathBlockAnimation(ActionSource.From, from);
   animation = this.buildUpdatedActivePathBlockAnimation(ActionSource.To, to, animation);
   this.store.dispatch(new SetAnimation(animation));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:9,代码来源:actionmode.service.ts

示例8: updateBlocks

 updateBlocks(blocks: ReadonlyArray<AnimationBlock>) {
   if (!blocks.length) {
     return;
   }
   const animation = this.getAnimation().clone();
   animation.blocks = animation.blocks.map(block => {
     const newBlock = _.find(blocks, b => block.id === b.id);
     return newBlock ? newBlock : block;
   });
   this.store.dispatch(new SetAnimation(animation));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:11,代码来源:layertimeline.service.ts

示例9: toggleSegmentSelections

 toggleSegmentSelections(
   source: ActionSource,
   segments: ReadonlyArray<{ subIdx: number; cmdIdx: number }>,
 ) {
   const selections = [...this.getSelections()];
   _.remove(selections, s => s.type !== SelectionType.Segment || s.source !== source);
   const type = SelectionType.Segment;
   const toggledSelections = this.toggleSelections(
     selections,
     segments.map(({ subIdx, cmdIdx }) => ({ type, source, subIdx, cmdIdx })),
   );
   this.store.dispatch(new SetActionModeSelections(toggledSelections));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:13,代码来源:actionmode.service.ts

示例10: splitSelectedPointInHalf

 splitSelectedPointInHalf() {
   const selections = this.getSelections().filter(s => s.type === SelectionType.Point);
   const { source, subIdx, cmdIdx } = selections[0];
   const activePath = this.getActivePathBlockValue(source);
   const pm = activePath.mutate();
   pm.splitCommandInHalf(subIdx, cmdIdx);
   this.store.dispatch(
     new BatchAction(
       this.buildUpdatedActivePathBlockAnimationAction(source, pm.build()),
       new SetActionModeSelections([]),
       new SetActionModeHover(undefined),
     ),
   );
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:14,代码来源:actionmode.service.ts


注:本文中的app/store.Store.dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。