jQuery's Ajax handler returns an array of arguments when its promise resolves, and the initial tuple is ([data], "status")
. I've found that when I use Bacon.fromPromise
, all I get back is the data. How would I get the status of the transaction, and how would I handle any actual failures from jQuery?
What I'm trying to do is download two bundles of data, of the same schema, from two different URLs and concatenate them. I think I've got the concatenation figured out, but the error handling is driving me nuts. Here's what I'm trying:
requestData = Bacon.fromPromise $.get @users_stories
requestRefs = Bacon.fromPromise $.get @reference_stories
success = (d, s) -> s == "success"
fetchFailure = requestData.map(success).not()
.merge(requestRefs.map(success).not())
fetchFailure.onValue => alert "Failed to download"