Javascript 使用typescript在storeon中分派操作
我正在编写我的浏览器扩展,并试图将storeon添加到我的代码中。 我不知道如何在调度中纠正写操作; 对于expample,我要分派此函数:Javascript 使用typescript在storeon中分派操作,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,我正在编写我的浏览器扩展,并试图将storeon添加到我的代码中。 我不知道如何在调度中纠正写操作; 对于expample,我要分派此函数: getTimeEntryInProgress() { let userId = this.localStorageService.get("userId"); this.timeEntryService .list(userId) .then(response => { let timeEntr
getTimeEntryInProgress() {
let userId = this.localStorageService.get("userId");
this.timeEntryService
.list(userId)
.then(response => {
let timeEntry = response.data.filter(
x =>
x.custom_fields[0].value === "false" ||
x.custom_fields[0].value === "0"
)[0];
this.setTimeEntryInProgress(timeEntry);
})
.catch(() => {
this.application.setIcon(IconStatus.TimeEntryEnded);
});
}
例如,这是我的商店模块之一:
export const timeEntryModule: Module<TimeEntryState, TimeEntryEvents> = store => {
store.on('@init', () => ({
timeEntries: [],
selectedTimeEntry: null,
timeEntryInProgress: null
}));
store.on('timeEntry/select', (state, selectedTimeEntry) => ({ selectedTimeEntry }));
store.on('timeEntry/inProgress', (state, timeEntryInProgress) => ({ timeEntryInProgress }));
}
export const timeEntryModule:Module=store=>{
store.on('@init',()=>({
时间项:[],
selectedTimeEntry:null,
timeEntryInProgress:空
}));
store.on('timeEntry/select',(state,selectedTimeEntry)=>({selectedTimeEntry}));
on('timeEntry/inProgress',(state,timeEntryInProgress)=>({timeEntryInProgress}));
}
可能有人能帮忙或提供有用的链接