Created
May 3, 2013 06:19
-
-
Save mgonto/5507508 to your computer and use it in GitHub Desktop.
Restangular Promise Enhanced
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
var buildings = Restangular.all("buildings").getList(); | |
// New promise after adding the new building | |
// Now you can show in scope this newBuildings promise and it'll show all the buildings | |
// received from server plus the new one added | |
var newBuildings = buildings.push({name: "gonto"}); | |
var newBuildingsSame = buildings.call("push", {name: "gonto"}); | |
// This is a promise of a number value. You can show it in the UI | |
var lengthPromise = buildings.get("length"); | |
lengthPromise.then(function(length) { | |
// Here the length is the real length value of the returned collection of buildings | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment