as a former Java Engineer I'm struggling to have an interface as callback in Typescript/Javascript.
I'm having a "worker" class where I call doWork(..., myWorkerCallback)
The callback consists of different callback methods.
interface WorkerCallback {
onWorkDone() : void
onError(message: String) : void
...
}
In my calling component I'd have a member that implements that Callback-Interface.
myWorkerCallback: WorkerCallback = {
onWorkDone() {
...
}
}
now I need to access the state of the React component inside these callback methods. So I need to bind this callback member, right? But how to bind this interface member