Saturday, September 10, 2016

Create JavaScript callback in GWT using JSInterop

hi

In JavaScript, in order to get the login status using the Facebook SDK, one has to call the FB.getLoginStatus like so:

FB.getLoginStatus(function(response) {    if (response.status === 'connected')        // DO SOMETHING        });


notice the function(response) { ... } that is passed as a parameter to getLoginStatus.

I am able to map the FB object in GWT with the proper JSMethods like so:

@JsType(isNative = true)

public static interface FB {

  void init(FBParamObj fbParamObj);

  void getLoginStatus(CustomCallbackFunction callbackFunction);

}


However, I'm not sure how to define the CustomCallbackFunction callbackFunction that I need to provide as a parameter to FB.getLoginStatus. FB.getLoginStatus is provided by the Facebook SDK so I can not change it. 


How do I create this JavaScript callback function in GWT so I can pass it to the FB SDK as a parameter? 

I'm sure I'm missing something very basic but I can't seem to find it in the documentation. 




Thank you for the help!

Tony

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment