-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Resource promise #1547
Resource promise #1547
Conversation
$resource attaches the promise returned from $http to the new resource as $q property. New resource also has $resolved property, which is set to true when $q is resolved.
making sure it works with latest upstream
Add tests to verify state of $q promise and $resolved properties for the default actions (get, query, save, delete)
$q and $resolved properties overwritten when data is received and promise is resolved. Add properties back into resource object.
|
I'm wondering if it would make sense to also setup $q and $resolved properties on the Resource contructor. The benefit would be that Resources returned using 'new' instead of a http call wouldn't need special handling in Javascript to check whether these are defined or not. To me it seems like a fairly common case..? |
|
I implemented this resource file into our app. The $q being associated with resource is actually a very nice feature. It was very simple to implement. $q.succuss(function(){logic}); Sped up our app dramatically. |
|
Thanks partap. Was looking for this lately. |
|
No prob, pappu... thanks for using it! :) Slight tangent: If/when it gets merged, do I get notified? Also, on the other end, how easy is it to merge if my base is older? (a month old now) If there are conflicts do you just reject the PR and tell me to update and merge on that end before re-submitting? Anybody have experience with using these within an organization that is more "bazaar" than "cathedral" oriented (in regards to who has authority to update the project master branch, that is)... Is there a better place to ask these questions? Is there a FAQ? :) |
|
"Thanks for your contribution! In order for us to be able to accept it, we ask you to sign our CLA (contributor's license agreement). CLA is important for us to be able to avoid legal troubles down the road. For individuals (a simple click-through form): For corporations (print, sign and scan+email, fax or mail): |
|
Angular Team: I have a cleaned up commit in my branch, don't commit this one. |
|
@mhevery I'm really excited to have this feature (thanks @partap!) but the things I wish this PR handled differently are:
I wanted to do a PR to fix these issues, but wasn't sure how to fully reconcile them in a way that would be acceptable to the Angular team. I don't suppose your cleaned up version addresses either of these concerns? (Edit for clarity) |
|
@jonbcard sorry, your issues are not addressed. While you bring up good issues, I am not sure how this would work in practice. This feature is mostly a stop gap measure, for complex things as you describe should be handled in the controller. |
|
Ping @partap Please sign CLA http://code.google.com/legal/individual-cla-v1.0.html so we can get this in. |
|
Looks like it landed already as f3bff27 |
Added promise properties $q and $resolved to resource object.
I put in some unit tests to make sure the properties are behaving as expected for get, query, save and delete operations.