Signatures of JavaScript functions in WebSharper

I am creating an ampify.js binding for WebSharper. ( https://github.com/aph5nt/websharper.amplifyjs ). When testing my extension, I found one problem with publishing / subscribing implementation.

I declared a subscription handler:

let subscribeFn (data:obj) = JS.Alert(data :?> string)

I created a subscription:

Amplify.Amplify.Subscribe("tryPubSub", subscribeFn)

When I want to unsubscribe, I will do the following:

Amplify.Amplify.Unsubscribe("tryPubSub", subscribeFn)

the problem is that subscribeFn translates into two different functions. If I debug the js code and check what happens in the amplify.js lib file, I get the following:

//this is what has been saved when I created a subscription
subscriptions[ topic ][ i ].callback
(L){return i.subscribeFn(L);}
.
//this is what was passed as a callback for the unsubscribe function
callback
(S){return i.subscribeFn(S);} 

There is no difference in logic, but the arguments are different, and because of this, I can not unsubscribe.

+4
source share
1 answer

WebSharper 3 ( ), .

, :

let subscribeFn = fun (o: obj) -> subscribeFn o

( - WebSharper 4 .)

+1

Source: https://habr.com/ru/post/1651528/


All Articles