本文整理汇总了TypeScript中@ngxs/store.StateContext.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StateContext.dispatch方法的具体用法?TypeScript StateContext.dispatch怎么用?TypeScript StateContext.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ngxs/store.StateContext
的用法示例。
在下文中一共展示了StateContext.dispatch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: processUpdateEvent
private processUpdateEvent(
ctx: StateContext<SourceModel[]>,
action: ObsDispatchEvent
) {
const state = ctx.getState();
switch (action.payload['update-type']) {
case 'SwitchScenes':
ctx.setState([...action.payload.sources]);
ctx.dispatch(new GetSourceMuteState());
break;
case 'SceneItemVisibilityChanged':
const newstate = state.map(x => {
if (x.name === action.payload['item-name']) {
x.render = action.payload['item-visible'];
}
return x;
});
ctx.setState([...newstate]);
break;
case 'SceneItemAdded':
case 'SceneItemRemoved':
case 'SourceOrderChanged':
ctx.dispatch(new GetCurrentScene());
break;
}
}
示例2: receiveEvent
@Action(ObsDispatchEvent)
receiveEvent(ctx: StateContext<SourceModel[]>, action: ObsDispatchEvent) {
if (action.payload['update-type']) {
this.processUpdateEvent(ctx, action);
return;
}
const { id, actionType } = this.service.getActionType(action.payload);
const state = ctx.getState();
switch (actionType) {
case 'GetSceneList':
action.payload.scenes
.filter(s => s.name === action.payload['current-scene'])
.map(scene => ctx.setState([...scene.sources]));
ctx.dispatch(new GetSourceMuteState());
break;
case 'GetCurrentScene':
ctx.setState([...action.payload.sources]);
ctx.dispatch(new GetSourceMuteState());
break;
case 'ToggleMute':
case 'GetMute':
const sources = state.map(source => {
if (source.name === action.payload.name) {
source.muted = action.payload.muted;
}
return source;
});
ctx.setState([...sources]);
break;
}
}
示例3: catchError
catchError((error: ApiResponse) => {
if (error.message.length > 0 && error.message.match(/storage/i)) {
this.notify.warning('Storage "' + payload + '" was not found.');
ctx.dispatch(new Navigate(['/admin/storages']));
} else {
this.notify.error('Could not retrieve repositories ' + payload + '!');
console.error('Could not retrieve repositories for storage ' + payload + '!', error);
}
return of(error);
}),
示例4: processUpdateEvent
private processUpdateEvent(
ctx: StateContext<TransitionModel[]>,
action: ObsDispatchEvent
) {
const state = ctx.getState();
switch (action.payload['update-type']) {
case 'TransitionListChanged':
ctx.dispatch(new TransitionLoad());
break;
}
}
示例5: hmrNgxsStoreBeforeOnDestroy
public hmrNgxsStoreBeforeOnDestroy(): Partial<S> {
let state: Partial<S> = {};
const ctx: StateContext<S> = this.context.createStateContext();
if (typeof this.ngAppModule.hmrNgxsStoreBeforeOnDestroy === 'function') {
state = this.ngAppModule.hmrNgxsStoreBeforeOnDestroy(ctx);
} else {
state = ctx.getState();
}
ctx.dispatch(new HmrBeforeDestroyAction(state));
return state;
}
示例6: GetCaptionList
.pipe(tap(() => ctx.dispatch(new GetCaptionList())));
示例7: GetCustomCSS
.subscribe(() => ctx.dispatch(new GetCustomCSS()));
示例8: GetAreaPosition
.subscribe(() => ctx.dispatch(new GetAreaPosition()));