Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Allow site key to be a promise #220

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ITachiLab
Copy link

Relates to: #219

This modification makes possible to pass a promise as a site key.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.8%) to 91.852% when pulling 3bff3a0 on ITachiLab:master into a187773 on VividCortex:master.

Copy link
Contributor

@TheSharpieOne TheSharpieOne left a 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.

@mtrias mtrias requested a review from iambrosi January 3, 2018 18:14
Copy link
Contributor

@iambrosi iambrosi left a 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;
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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.

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.

4 participants