Error Propagation with Middlewares
// main.ts
aurelia.use.plugin('aurelia-store', {
initialState,
propagateError: true, // Enable error propagation
});// app.ts
import { inject, PLATFORM } from 'aurelia-framework';
import { Store, MiddlewarePlacement, StateHistory } from 'aurelia-store';
import { State } from './state';
const errorThrowingMiddleware = (currentState: StateHistory<State>) => {
throw new Error('Something went wrong in the middleware!');
};
@inject(Store)
export class App {
constructor(private store: Store<StateHistory<State>>) {
this.store.registerMiddleware(
errorThrowingMiddleware,
PLATFORM.moduleName('before')
);
}
}Last updated
Was this helpful?