Skip to content

Instantly share code, notes, and snippets.

@tomasdev
Created February 4, 2014 16:11
Show Gist options
  • Save tomasdev/8806741 to your computer and use it in GitHub Desktop.
Save tomasdev/8806741 to your computer and use it in GitHub Desktop.
// LikePhoto.js
exports.main = function(request, response){
var query = new Parse.Query("Photo");
var objid = request.params.objectid;
return query.get(objid)
// Photo
.then(function(photo) {
// GENERIC LOGIC FOR ALL LIKE PHOTOS here.
// ...
return Notifications.sendNotifications(opts);
}, function(error) {
// error handler
})
// Notification
.then(function (notif) {
// notif here will be the returned value of sendNotifications()
response.success(likesCounter);
}, function () {
// Whatever on notification error
});
};
// Notifications.js
exports.sendNotifications = function (opts) {
return query.get(userID).then(function (user) {
// On Success
// THIS WILL BE GIVEN TO THE NEXT .then() - WHOEVER CALLS sendNotifications().then()
return addNotification(etc);
}, function () {
// Failure
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment