Search code examples
google-drive-apigoogle-drive-realtime-api

Realtime API for model synchronization


I am looking to extend an existing JavaScript/CoffeeScript application using the realtime API. What I want to do is synchronize a map used by the Model of my application, part of an MVC framework spinejs. This would require that all the operations of the API will be done on the Model of my application (which is pure client-side), and have no direct interaction with the View.

All the open-source examples of realtime-api I have found had the JS code within the HTML being displayed, or much of the operations for authorization/loading etc (quickstart,realtime-cube,realtime-playground).

Is it possible to use realtime-api, without having direct interaction with the displayed content?

Furthermore, if any examples are available it would be greatly appreciated.


Solution

  • Once the auth is done, all the operations can be performed, without any user operation being necessary (i.e. they don't have to be triggered by a user event).

    I can show you our RT code here, although it's non-trivial, the listeners are listening to our own model, which cause RT functions to be invoked.

    In terms of the auth, it works fine, except if you want to support multiple accounts. For single accounts you can use the immediate mode to enable signing in without causing a popup.

    If there are multiple accounts logged in, you will need a user event to start the auth without having a popup, immediate mode messes up multiple account handling. Note there is a bug in the multiple account selection screen anyway, which causes a poor user experience.