Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

I'm confused with unknown for bindings

$
0
0

If there is a predictable amount of combinations, I would write multiple bindings for the same function.

@send external onpushString: (ftwebsocket, (~cmd: string, ~res: string) => unit) => unit = "onPush"

@send external onpushInt: (ftwebsocket, (~cmd: int, ~res: int) => unit) => unit = "onPush"

@send external onpushFloat: (ftwebsocket, (~cmd: float, ~res: float) => unit) => unit = "onPush"

Or you could use a generic type for the function which defines the cmd and res type

type onpush<'cmd, 'res> = (free socket, ~cmd: 'cmd, ...

@send external onpushFloat: onpush<float, float> = "onPush"

Viewing all articles
Browse latest Browse all 2592

Trending Articles