-
Notifications
You must be signed in to change notification settings - Fork 257
Allow site key to be a promise #220
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but you shouldn't change the release files. Those get generated when a release is created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheSharpieOne @mtrias I'd like to know your thoughts on my comments.
scope.$watch('required', validate); | ||
} | ||
|
||
var removeCreationListener = scope.$watch('key', function (key) { | ||
// Abort if undefined or null | ||
if (ng.isUndefined(key) || key === null) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This early return prevents the service from throwing an error when the key is undefined. Check the failing test.
'expired-callback': expired | ||
|
||
// Accept a promise, or resolve immediately if the value is a bare string | ||
$q.resolve(key).then(function (resolved) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this should go in the service and not in the directive. The support for key-as-promise would be complete in this project, since ATM the service doesn't support a key as promise.. Also, it could make testing the directive simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should we use $q.when
instead of $q.resolve
? The latter was added in Angular 1.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to have the feature in the service as well as the directive.
$q.when
should be used for the reason mentioned above, more support.
Relates to: #219
This modification makes possible to pass a promise as a site key.