Greetings.
I read the Unknown for type safety section, but then I got stuck. How to actually make getPropertySafe work?
I was writing bindings for an external library. There is a sub/push mechanism. I think you guys can got an idea from the following code:
websocket.onPush = (cmd, res)=>{
if(ftCmdID.QotUpdateOrderBook.cmd == cmd){
let { retType, s2c } = res
if(retType == RetType.RetType_Succeed){
console.log("OrderBookTest", s2c);
} else {
console.log("OrderBookTest: error")
}
}
};
I wrote the binding for onPush like this: @send external onpush: (ftwebsocket, (~cmd: int, ~res: unknown) => unit) => unit = "onPush". The res type shape depends on the matched cmd.
What’s the proper way to do these kind of bindings? Thanks!