我实现了一个与this完全相同的示例项目,但我得到了Uncaught ReferenceError: Invalid action reference passed in
。运行时在我的商店中抛出此错误:
this.bindListeners({
handleRefreshComponentLibrary: ComponentLibraryActions.refreshComponentLibrary,
handleComponentLibraryRefreshed: ComponentLibraryActions.componentLibraryRefreshed,
handleComponentLibraryRefreshFailed: ComponentLibraryActions.componentLibraryRefreshFailed
});
我引用的动作如下所示:
interface Actions{
refreshComponentLibrary():void;
componentLibraryRefreshed(componentLibrary: MqtlComponent[]):void;
componentLibraryRefreshFailed(errorMsg:string):void;
}
class ComponentLibraryActions extends AbstractActions implements Actions{
constructor(){
super(altInstance);
this.generateActions(
"refreshComponentLibrary",
"componentLibraryRefreshed",
"componentLibraryRefreshFailed"
)
}
refreshComponentLibrary(){
console.log("ACTION!!! Refresh comp library");
this.dispatch();
//Trigger async
ComponentLibraryStore.fetchComponentsFromServer();
}
componentLibraryRefreshed(componentLibrary: MqtlComponent[]){
console.log("Dispatch action: Library refreshed");
this.dispatch(componentLibrary);
}
componentLibraryRefreshFailed(errorMsg: string){
console.log("Dispatch action: Library refresh failed");
this.dispatch(errorMsg);
}
}
export = altInstance.createActio
在没有this.generateActions(...)的情况下尝试过它,但没有运气......
我不确定我的动作是否在结构上与alt.d.ts定义它们相同但我完全像在教程中那样(我认为这样做是正确的)。< / p>
有什么想法吗?是否存在将操作绑定到商店的替代方法?