Commits

Matthew Schinckel committed 8b5383e

Add docs for callback version.

Comments (0)

Files changed (1)

 
 ## Usage
 
+### Delegate
+
     <script>
       $(function(){
         // Put the listeners you want in this.
         var delegate = {};
         var g = Garmin.Communicator(delegate, true);
-      })
+      });
     </script>
 
 This will inject the plugin into the page if it isn't already there, create a new instance of the `Communicator` controller, and (if the second argument is true), start looking for devices right away.
 
 Your delegate's attributes that match the various events are then called when an event occurs. You can also manually set listeners for the events like `$(document).on('onFinishReadFromDevice', handler)`. The handler will recieve a jQuery Event object, and depending upon the event, there may also be a `data` object. Event.data contains a reference to the controller object.
 
+### Callback
+
+    <script>
+      $(function() {
+        var g = Garmin.Communicator();
+        g.selectDevice(0);
+        // Read activities from the device.
+        g.readActivities(function(data) {
+          // data contains XML!
+        });
+        // Write workouts to the device.
+        g.writeWorkouts("<Valid XML data>");
+      });
+    </script>
+    
+This usage is new: there may still be some bugs (like things happening before the devices are loaded), as I'm still looking into the bare constructor.
+
 ## Events
 
+To be finalised. Source code contains some info about this, but may change.
+
 ### onStartFindDevices
 
 Called before the search for devices occurs.