Last active
August 29, 2015 14:02
-
-
Save Retozi/957aba405c8e611f5ec9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeDigestFun(key, callback) { | |
return function (err, res) { | |
clearRequestQueue(key); | |
if (err && err.timeout === TIMEOUT) { | |
callback(ASYNC.TIMEOUT); | |
} else if (res.status === 400) { | |
Api.logout(); | |
} else if (!res.ok) { | |
callback(ASYNC.ERROR); | |
} else { | |
callback(res); | |
} | |
}; | |
} | |
function get(url) { | |
return request | |
.get(url) | |
.timeout(TIMEOUT) | |
.query({authtoken: _token}); | |
} | |
Api = { | |
getUserLists: function(callback) { | |
var key = 'user-lists'; | |
startRequest(key, callback); | |
_pendingRequests[key] = get(makeUrl("/user-lists")).end(makeDigestFun(key, callback)); | |
}, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function activateEntity (id) { | |
if (id) { | |
Api.getEntityData(id, function(res) { | |
if (ASYNC.isAny(res)) { | |
updateEntityData(res); | |
} else { | |
updateEntityData(res.body.entity); | |
} | |
}); | |
} else { | |
updateEntityData(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment