Tuesday, March 19, 2013 | 9:00 AM
By Brian Cairns, Software Engineer
Google Drive lets users create Docs, Sheets, and Slides, collaborate on them in real time, and have their changes saved automatically. With the new Google Drive Realtime API, you can now easily add some of the same real-time collaboration that powers Google Drive to your own apps. This new API handles network communication, storage, presence, conflict resolution, and other collaborative details so you can focus on building great apps.
Developing for the Drive Realtime API is almost as simple as working with local objects. The API provides collaborative versions of familiar data objects such as maps, lists, strings, and JSON values and automatically synchronizes and stores modifications to these objects. Your application reads from and writes to these objects like any other local object. Change event handlers can be added to collaborative objects so that your app can react to changes from other collaborators.
Because the Drive Realtime API is based on operational transformation (OT), local changes are reflected instantly, even on high-latency networks. The Drive Realtime API automatically transforms changes to the data model so that every collaborator stays in sync.
If basic collections aren't enough for your application, the Drive Realtime API supports custom objects and references, including trees and arbitrary graph structures. As with other collaborative objects, the Drive Realtime API automatically synchronizes these objects with other collaborators and stores them in Drive.
Because presence is important in collaborative applications, the Drive Realtime API also keeps track of who is connected to your application and provides your app with events for when collaborators join, leave, or make changes.
|Widget using the Drive Realtime API and showing the collaborators on a document|
Neutron Drive, Gantter and draw.io have enabled realtime collaboration in their apps using the Google Drive Realtime API. Check out these apps to see the Drive Realtime API in action.
Collaborative code editing with Neutron Drive
Neutron Drive is an online editor for text and source code files stored in Google Drive. You can now collaboratively edit any text or source code files stored in Drive and get a realtime collaboration experience—shared typing, a view of active collaborators, cursor positioning, and selected text. This all comes in addition to the syntax highlighting and other advanced features offered by Neutron Drive. To learn more, watch the video:
Collaborative project scheduling with Gantter
Gantter is a free online project scheduling tool and Gantt diagram editor. It now allows you to collaboratively—and in real time— work on your project schedules. It even features an embedded chat powered by the Drive Realtime API. Watch the video below to see Gantter’s new realtime collaboration features in action.
Collaborative diagraming with draw.io
draw.io is a diagraming application that enables you to draw a wide variety of diagrams such as flowcharts, UML diagrams and even electronic circuits. You can now see updates from other collaborators instantaneously, with colored visual cues indicating who has changed the diagram and where that change occurred. Try the new draw.io collaborative beta at rt.draw.io and watch the video below.
Learn more about the Drive Realtime API
We built a collaborative colored cube puzzle so you can have some fun while trying out the Drive Realtime API and a Drive Realtime API Playground to take you through the API step-by-step. Both apps are open source so check out our Github repos.
Have a look at the Google Drive Realtime API technical documentation and start making your app realtime-enabled!
Brian Cairns joined the Google Drive team in 2011 and lives in Boulder, Colorado. He is the lead software engineer for the Drive Realtime API.
Posted by Scott Knaster, Editor