Is it possible to use a JS based API like the Google Hangouts API with Dart?

49 views
Skip to first unread message

Brendon Duncan

unread,
Feb 29, 2012, 6:52:11 PM2/29/12
to General Dart Discussion
I'm writing a web app in Dart, I'd like to be able to use it inside a
Google+ Hangout too. It seems that the Hangouts API is specified with
a Javascript interface, with no RESTFUL web API available. Here's the
link:

https://developers.google.com/+/hangouts/reference

Is it possible to do this at all with Dart? Reverse engineering the
interface from the js file would probably take too long for it to be
feasible, especially with a moving target. If I really wanted to be
able to use it as a Google+ Hangouts app, then I would have to go back
to js which is something that I really don't want to do.

What other options are there?
Brendon

Bob Nystrom

unread,
Feb 29, 2012, 7:21:12 PM2/29/12
to Brendon Duncan, General Dart Discussion
Our JS interop story is still in flux so there aren't any easy answers here. I think what you could do is write most of your app in Dart. Then write a (hopefully small) shim layer in JS that talks to the Hangouts API and routes it through postMessage(). You can then pick that up in Dart and take it from there.

At least I think that's the way you can do it. This isn't my area of expertise.

- bob

Seth Ladd

unread,
Feb 29, 2012, 7:45:34 PM2/29/12
to Bob Nystrom, Brendon Duncan, General Dart Discussion
I've done exactly this when I needed to run some JavaScript code from within Dart. I used postMessage() between Dart and the host page, capturing it in JavaScript. I used this more for course grained signaling, I didn't try to do anything real-time.

Eli Brandt

unread,
Feb 29, 2012, 8:02:47 PM2/29/12
to Bob Nystrom, Brendon Duncan, General Dart Discussion
Yep, as far as I know this is the state of the art.

I forget who had the idea, but we've had discussion about writing an "all-purpose" shim in JS.  Handwaving, it would live on the JS side, receive structured strings, and execute the fn calls they specify.  Nobody's got concrete plans to write this that I've heard of.

This would not be blindingly fast, but we aren't recommending tight fine-grained intercalling between Dart and JS.

Eli

On Wed, Feb 29, 2012 at 4:21 PM, Bob Nystrom <rnys...@google.com> wrote:
Reply all
Reply to author
Forward
0 new messages