Skip to content

Commit

Permalink
refactor: em
Browse files Browse the repository at this point in the history
  • Loading branch information
akastercomcom committed Sep 19, 2023
1 parent d4a8b8d commit 952e231
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/handlers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ import EventManager from "@ainblockchain/ain-js/lib/event-manager";

export default class Handler {
private static instance: Handler | undefined;
ain = AinModule.getInstance();
em: EventManager | undefined;
em = AinModule.getInstance().getEventManager();
static getInstance() {
if(!Handler.instance){
Handler.instance = new Handler();
Handler.instance.em = Handler.instance.ain.getEventManager();
}
return Handler.instance;
}

checkEventManager() {
if (!this.em)
throw new Error('set eventManager First.');
if (!this.em) {
if(!AinModule.getInstance().getEventManager()){
throw new Error('you should init ain first');
}
this.em = AinModule.getInstance().getEventManager();
}
return true;
}

Expand Down

0 comments on commit 952e231

Please sign in to comment.