My directive has a custom event, say my-event
used like:
<div (my-event)="handle($event)">
and user handles the event like:
async handle(e) {
await handleEvent(e);
}
Then I like to perform a specific action after the event is handled by user-provided code like above.
Currently what I am doing is to provide a done
function from the directive:
// ...
this.myEvent.emit({ event: e, done: this.done });
}
done = () => { /* do something */ };
And let user call done
function once it finished handling the event:
async handle({ event, done }) {
await handleEvent(event);
done();
}
My question: Would it be possible to move calling-done
-part from user code to the directive so that user just handles the event as required without worrying about calling done
function?