Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Conversation

@partap
Copy link
Contributor

@partap partap commented Nov 9, 2012

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.

Partap Davis added 5 commits October 24, 2012 14:40
$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.
@jonbcard
Copy link
Contributor

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..?

@joshkurz
Copy link
Contributor

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.

@pappu687
Copy link

pappu687 commented Dec 5, 2012

Thanks partap. Was looking for this lately.

@partap
Copy link
Contributor Author

partap commented Dec 6, 2012

No prob, pappu... thanks for using it! :)

Slight tangent:
This is my first pull request, and I'm kinda curious as to exactly how they work. I just read this post, and it's raised more questions....

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? :)

@ghost ghost assigned mhevery Jan 17, 2013
@mhevery
Copy link
Contributor

mhevery commented Jan 17, 2013

"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):
http://code.google.com/legal/individual-cla-v1.0.html

For corporations (print, sign and scan+email, fax or mail):
http://code.google.com/legal/corporate-cla-v1.0.html"

@mhevery
Copy link
Contributor

mhevery commented Jan 17, 2013

Angular Team: I have a cleaned up commit in my branch, don't commit this one.

@jonbcard
Copy link
Contributor

@mhevery I'm really excited to have this feature (thanks @partap!) but the things I wish this PR handled differently are:

  • Calling instance methods on a resource (e.g. $save) overwrites the original $q and $resolved object properties. This would have funny effects, for example, if you were trying to use $resolved to control visibility of an edit form (which I assume would be the primary sort of purpose of this flag). The form would disappear as soon as you clicked the save button, then reappear when the response comes back.
  • Promise callbacks get passed the $http response instead of the Resource object(s). IMO. this isn't all that intuitive (unless the intention here is to expose the $http response details instead of giving ngResource promise behaviour).

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)

@mhevery
Copy link
Contributor

mhevery commented Jan 18, 2013

@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.

@mhevery
Copy link
Contributor

mhevery commented Jan 19, 2013

Ping @partap Please sign CLA http://code.google.com/legal/individual-cla-v1.0.html so we can get this in.

@pkozlowski-opensource
Copy link
Member

Looks like it landed already as f3bff27

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants