Open
Description
I'm trying to define a component interface in WIT format so that components (client) can pass callbacks (closures) to host. Host can then store the callback somewhere and then invoke the callback when certain event happens.
I'm a bit confuse how can I describe this using WIT format. I'm thinking of something like this:
package foo:bar
world client {
resource callback {
// Invokes the callback
call: func()
}
// Passes the callback from client to host
import register-callback: func(callback: callback)
// The main function for the client
export main: func()
}
But because I didn't export the resource (I can't do export callback
apparently), I guess this is treated as if callback
is implemented by the host, which is not I want. I can change it to:
package foo:bar
interface host {
use callback-types.{callback}
register-callback: func(callback: callback)
}
interface callback-types {
resource callback {
call: func()
}
}
interface client {
use callback-types.{callback}
run: func()
}
world client-world {
import host
export client
}
But then, will host/callback
and client/callback
be treated as the same type?
Metadata
Metadata
Assignees
Labels
No labels