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.
source
share