Polling and the Drive changes API


This topic was covered on Totally Unscripted 5 (TU5).

You'll find the Youtube Channel here.

Polling

I've already covered polling for changes in a number of articles such as Watching for server side changes from the client html service, but for the TU5, I made a cut down add-on to demonstrate the principles of how this works. In order to watch for changes of data, position or selected range in a sheet attached to an add-on, it's necessary to continually poll the server from the client. The techniques covered in TU5 show how to do this with minimal disruption to your client App. For the demo, we'll be using an add-on in test mode along with a sheet with some test data. 
It looks like this, and is available for playing around with here




Drive changes API


In the Drive JSON API v3, it's now possible to listen for changes to files on Drive. This could be an alternative approach to polling, but if you need to watch for changes in active selection as well as data changes, you won't be able to do it with this API. For TU5, I created a handy little webapp to monitor and report on changes in your Drive to be talked about on the show too.  It looks like this, and the web app is publicly available here



Code


The demo code is here and on github






For more like this, see Google Apps Scripts snippets. Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
Comments