Changes between Version 21 and Version 22 of Clojure Client Tutorial
- Timestamp:
- Aug 4, 2011 3:13:09 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Clojure Client Tutorial
v21 v22 161 161 client.protocol-one/send-and-get 162 162 ([quagent id msg] [quagent id msg f]) 163 Send a op to the server and block this thread until the op completes. Args are a (unique) op id, a msg to send to the server and a function f that determines how to combine the current reply from the server with past results (defaults to conj). 163 Send a op to the server and block this thread until the 164 op completes. Args are a (unique) op id, a msg to send 165 to the server and a function f that determines how to 166 combine the current reply from the server with past 167 results (defaults to conj). 164 168 nil 165 169 }}} … … 170 174 client.protocol-one/send-and-get-later 171 175 ([quagent id msg] [quagent id msg f]) 172 This will spawn a separate thread to do the send and get, if you try to dereference it before it has completed, it will block. Use future-done? to check the status before dereferencing. 176 This will spawn a separate thread to do the send and get, 177 if you try to dereference it before it has completed, 178 it will block. Use future-done? to check the status before 179 dereferencing. 173 180 nil 174 181 }}} … … 179 186 client.protocol-one/send-and-watch 180 187 ([quagent id msg wf] [quagent id msg f wf]) 181 Sends the op to the server and then applies f to update the value. When the value changes wf is called (wf must meet the requirements of the add-watch function). The return value is the key for the watcher; this is used to delete it if necessary [(example)](http://clojure-examples.appspot.com/clojure.core/add-watch?revision=1278516003572). 188 Sends the op to the server and then applies f to update the value. 189 When the value changes wf is called (wf must meet the requirements 190 of the add-watch function). The return value is the key for the 191 watcher; this is used to delete it if necessary 192 [(example)](http://clojure-examples.appspot.com/clojure.core/add-watch?revision=1278516003572). 182 193 nil 183 194 }}} … … 187 198 188 199 {{{ 189 client.core=> (defn get-location-of [quagent] (client->server send-and-get quagent :now :current-location nil)) 200 client.core=> (defn get-location-of 201 [quagent] 202 (client->server send-and-get quagent :now :current-location nil)) 190 203 #'client.core/get-location-of 191 204 }}}