Examples
Synchronizing a few API calls.
<script type="text/javascript"> function getDatabases( sync_obj ) { new SK.API( null // Will use the current session ID ).execute( 'db.get_all', {}, function( success, message, data ) { // Dump the list if ( success ) { data.databases.each(function(d){ $('log').grab( new Element( 'div', { text: d.name } ) ); }); // Tell the SK.Sync library the execution of this function has finished this.sync_obj.ready( ); } else { this.sync_obj.failure( message ); } }.bind( { sync_obj: sync_obj } ) ); }
function pause( sync_obj ) { $('log').grab(new Element( 'hr' )); sync_obj.ready( ); // Tell the library we're done }
function testDone( ) { $('log').grab(new Element( 'div', { text: 'Done!' } ) ); }
function testFailure( message ) { $('log').grab(new Element( 'div', { text: 'FAILURE: ' + message } ) ); }
var sync_obj = new SK.Sync( [ getDatabases, pause, getDatabases, pause, getDatabases ], testDone, testFailure );
sync_obj.run( ); </script> <div id="log"></div>
|