Controller.tsx 341 B

1234567891011121314151617
  1. import { Observable } from './Observable';
  2. type errorProps = {
  3. _hasError?: boolean;
  4. }
  5. export class Controller<S, T> extends Observable<S & errorProps, T> {
  6. onError (desc: any) {
  7. this.state._hasError = true;
  8. console.error(desc);
  9. this.dispatch();
  10. }
  11. hasError (): boolean {
  12. return this.state._hasError === true;
  13. }
  14. }