aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-04-18 08:43:36 +0100
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-04-18 08:51:12 +0100
commit0f1279fbed3fa5ceccb805e8453c365a6c51879b (patch)
tree15d1208af036c36aabcbcab77b3959264d88ba0f
parent9656457f6c00441ffed8eb6b633080a0316a4a0f (diff)
Add CALLBACK to sx-method-call
-rw-r--r--sx-method.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/sx-method.el b/sx-method.el
index 065f8d6..98d510b 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -43,6 +43,7 @@
get-all
(process-function
#'sx-request-response-get-items)
+ callback
site)
"Call METHOD with additional keys.
@@ -62,6 +63,8 @@ PROCESS-FUNCTION is a response-processing function
PAGE is the page number which will be requested
PAGESIZE is the number of items to retrieve per request, default
100
+CALLBACK is a function to be called if the request succeeds. It
+is given the returned result as an argument.
When AUTH is nil, it is assumed that no auth-requiring filters or
methods will be used. If they are an error will be signaled. This is
@@ -136,11 +139,14 @@ Return the entire response as a complex alist."
(push `(pagesize . ,pagesize) keywords))
(when site
(push `(site . ,site) keywords))
- (funcall call
- full-method
- keywords
- url-method
- (or get-all process-function))))
+ (let ((result (funcall call
+ full-method
+ keywords
+ url-method
+ (or get-all process-function))))
+ (when callback
+ (funcall callback result))
+ result)))
(defun sx-method-post-from-data (data &rest keys)
"Make a POST `sx-method-call', deriving parameters from DATA.