ibdknox/fetch — Issue #5: Wait for return from server
Author: djhworld
Created: 2012-02-24 22:14:13+00:00
State: open

I understand that ```fetch``` has a callback model style for development, however I'm having trouble trying to work with this model effectively in my current application.

I'm developing a small CLJS application that has a "console" style interface, so the user inputs commands and I have a "handle" function that takes the input the user has submitted, parses it, and performs an action that ultimately returns a string as a result.

One of these functions goes to the server to return a map of data, however due to the nature of ```fetch``` it does nothing because nothing is "returned" from a ```remote``` until the callback function is called

e.g.

```clj
(defn get-results-from-server [arg]
(fm/remote (get-results arg) [r]
r))

(defn command-handler [input arg]
(condp = input
"get" (-> (get-input-from-server arg) (js/alert))) ;js alert doesn't show anything as nothing is 'returned' from get-results-froms-sever
...
```

Is there any way of making ```fetch``` request data from the server, wait for a reply (or timeout with a nil result) and then return whatever was received, instead of a callback?

Sorry if that doesn't make sense