Saturday, March 3, 2018

Re: GWT and Cordova/PhoneGap - use JsInterop?

I've done GWT on top of Cordova for one app: https://www.wobastic.com/omber . It's certainly a quick way to get something running on mobile. Just use GWT to generate your web page. Copy everything into a Cordova project. Write a cordova configuration file. Run some Cordova commands, and then everything seems to run. I just used a combination of JSNI and JSInterop to hook into Cordova and its plugins when I needed to.

Things sort of fall apart once you need to start doing things that don't normally run in a browser or when you want to properly handle all the weird cellphone things like pause and resume. In those cases, the documentation becomes a little difficult to understand. And the abstractions that try to hide the difference between iOS and Android don't really work, so you end up having to read two or three separate documents about what the API is, another on how the API works on Android, yet another on how the API works on iOS, and then the actual Android and iOS documentation because none of that made sense. And Cordova seems to have pushed a lot of the non-browser, platform-specific stuff into community-supplied plugins. But the plugins are like StackOverflow, a wild west of random code of varying quality written by random people. There might be GWT plugins for that stuff, but I don't think so. I imagine there are enterprise offerings of Cordova that offer properly supported plugins, but I never bothered digging into there.

I did that for two years, but I recently got fed up and just wrote my own code for embedding a webview in a mobile app. It turns out Cordova doesn't actually do much. If you've got a month to spare, if you don't think very highly of JavaScript programmers, and if you've got the patience to write a lot of annoying glue code, then rolling your own is definitely the way to go. No poorly documented, slightly buggy plugins. You just call out to your own Android/iOS code, then cut & paste some sample code directly from the Android/iOS documentation with what you need to do, and then return the result. 

You do end up needing to have separate variations of your GWT app for web, Android, and iOS, but you would need to do that anyway with Cordova because the Cordova abstractions are sort of leaky.

Mind you, I also hate using JavaScript frameworks (other than GWT), and just use vanilla.js for everything, so keep that in mind before taking my advice.

--
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