Created
February 10, 2014 14:22
-
-
Save fterrier/8916751 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// d: initial data | |
// cs: success callback | |
// cf: failure callback | |
var flows = { | |
'get_likes': function(d, cs, cf) { | |
likes_api | |
.get_likes(d) | |
.then(cs, cf); | |
}, | |
'read_set_read_remove_read_likes': function(d, cs, cf) { | |
likes_api | |
.get_likes_by_user(d, function(body) { | |
// make sure that the user has no likes | |
return body.likes.length === 0; | |
}) | |
.then(function(d) { | |
likes_api.set_like_for_user_and_item(d, function(body) { | |
// we test that it's set | |
return | |
true | |
}, function(new_data) { | |
return new_data; | |
}) | |
}, cf) | |
.then(function(d) { | |
likes_api.get_likes_by_user(d, function(body) { | |
logger.info("test", body); | |
return true; | |
}, function(new_data) { | |
return new_data; | |
}) | |
}, cf) | |
.then(likes_api.remove_like_from_user_and_item, cf) | |
.then(cs, cf); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah ja und d muss in diesem Fall umbenannt werden.
temp_d
in meinem Fall, da es sonst mit dem ersten aus irgend einem Grund kollidiert, was es nicht tun sollte.