angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

feat(q): add isPromiseLike

Open wesleycho opened this issue 10 years ago • 2 comments

  • Add isPromiseLike public method for determining whether value is a promise-like object

This addreses #13372.

My only concern with this implementation is that IMO this doesn't really belong on $q, but maybe on the angular global itself.

wesleycho avatar Dec 26 '15 03:12 wesleycho

I expect that this change makes $q fail the Promise/A+ compliance test

On Saturday, December 26, 2015, Wesley Cho [email protected] wrote:

  • Add isPromiseLike public method for determining whether value is a promise-like object

This addreses #13372 https://github.com/angular/angular.js/issues/13372.

My only concern with this implementation is that IMO this doesn't really

belong on $q, but maybe on the angular global itself.

You can view, comment on, or merge this pull request online at:

https://github.com/angular/angular.js/pull/13634 Commit Summary

  • feat(q): add isPromiseLike

File Changes

  • M lib/promises-aplus/promises-aplus-test-adapter.js https://github.com/angular/angular.js/pull/13634/files#diff-0 (1)
  • M src/Angular.js https://github.com/angular/angular.js/pull/13634/files#diff-1 (2)
  • M src/ng/q.js https://github.com/angular/angular.js/pull/13634/files#diff-2 (23)
  • M src/ngAnimate/shared.js https://github.com/angular/angular.js/pull/13634/files#diff-3 (4)
  • M test/ng/qSpec.js https://github.com/angular/angular.js/pull/13634/files#diff-4 (20)

Patch Links:

  • https://github.com/angular/angular.js/pull/13634.patch
  • https://github.com/angular/angular.js/pull/13634.diff

— Reply to this email directly or view it on GitHub https://github.com/angular/angular.js/pull/13634.

lgalfaso avatar Dec 26 '15 08:12 lgalfaso

Removed the change to $q's $$resolve method - it does take away some of the motivation for this method being implemented though.

Some caveats - I'm not sure whether this function should be exposed on $q or angular. Another thing is that the change in ngAnimate appears to not be used, but if it were, it would have perf implications.

wesleycho avatar Dec 26 '15 14:12 wesleycho