Created
February 4, 2014 16:11
-
-
Save tomasdev/8806741 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
// 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