WebSharper's client side can call methods that are themselves in [<JavaScript>]
scope or marked [<Remote>]
for remote calls. The error message is not mentioning the second option, but that is what you need here (same as the sample function DoSomething
has it too).
You will also need to make the remote function to not send over an obj
but a string
. Remote function arguments are deserialized based on type information and cannot be obj
. For example in client code, use Server.receive rvInput.Value
. (rvInput
is a reactive variable for which .Value
contains current value)
Note that if you want to return a value to the server, the remote function must be an async
. Here, just for logging, returning unit
works too, but then you have no way on the server to determine if the logging was successful. By returning an async<unit>
, you can catch errors in the client code if you want to guard against connection or server errors. Again, the sample code in the template gives some guidance.