Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

React: Typescript/Javascript Interface as Callback and accessing state

$
0
0

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


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>