Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexspeller/9604552 to your computer and use it in GitHub Desktop.
Save alexspeller/9604552 to your computer and use it in GitHub Desktop.
function getFeedsList() {
return new RSVP.Promise(function(resolve, reject) {
function getFeedsKeys() {
client.smembers("feeds", function(error, obj) {
if (error) throw(error);
return obj;
});
}
function getFeedsMetadata(feedsKeys) {
client.mget(feedsKeys, function(error, obj) {
if (error) throw(error);
return obj.map(function(currentValue, index, array) {return JSON.parse(currentValue);});
});
}
try {
var keys = getFeedsKeys();
var metadata = getFeedsMetadata(keys);
resolve(metadata);
} catch (err) {
reject(err);
}
});
}
getFeedsList().then(fetchFeeds, handleFeedsListError);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment