Hello again! I am working on the same stuff I was ...
# javascript
a
Hello again! I am working on the same stuff I was working on yesterday and Im now trying to bind an event to an external class. The javascript code I would use to react to the event is this:
Copy code
client.on(('ready'), msg => { // do stuff here })
How can I define this event in my external class and how do I then use it?
a
What object type is client? is it defined externally?
a
You can just add the
on
function to the
external class
definitions like so:
Copy code
external class Client {
  fun on(eventType: String, callback: (Message) -> Unit)
}
You can either go down the route of defining the
Message
interface too, or just pass
dynamic
to the callback
👍 1
a
Thanks!