web api preso cont.
authorBill Erickson <berickxx@gmail.com>
Thu, 7 May 2015 21:50:56 +0000 (17:50 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 7 May 2015 21:50:56 +0000 (17:50 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
api_presentation/web_apis.asciidoc

index a4a9459..41f23dc 100644 (file)
@@ -221,6 +221,44 @@ Received Data: {
 srfsh# request open-ils.pcrud open-ils.pcrud.retrieve.aou "ANONYMOUS", 1
 ---------------------------------------------------------------------------
 
+== PCRUD JavaScript Interface (pre-browser client)
+
+[source,js]
+---------------------------------------------------------------------------
+var pcrud = new openils.PermaCrud();
+
+pcrud.retrieve('aou', 1, {oncomplete : function(org) { ... }});
+pcrud.update(some_org, {oncomplete : function(resp) { ... }});
+
+pcrud.search('aou', {parent_ou : 1}, {   
+    oncomplete : function(r) {
+        var orgs = openils.Util.readResponse(r);
+        console.log('org units: ' + orgs);
+    }
+});
+
+---------------------------------------------------------------------------
+
+== PCRUD JavaScript Interface (browser client)
+
+ * Uses promises
+ * Defaults to streaming searches
+
+[source,js]
+---------------------------------------------------------------------------
+egCore.pcrud.retrieve('aou', 1).then(function(org) { ... });
+egCore.pcrud.update(some_org).then(function(resp) { ... });
+
+egCore.pcrud.search('aou', {parent_ou : 1})
+.then(
+    function() {...},   // oncomplete
+    function() {...},   // onerror
+    function(one_org) { // onresponse
+        console.log('one org unit: ' + one_org);
+    }
+});
+---------------------------------------------------------------------------
+
 == When Not To Use PCRUD
 
  * PCRUD is powerful enough to implement most logic in the client, but 
@@ -274,6 +312,7 @@ open-ils.fielder.flattened_search
 ---------------------------------------------------------------------------
 
 
+
 == Questions / Comments
 
  * Slides