Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set loading state when promise is set after click #12

Merged
merged 3 commits into from Jul 17, 2017
Merged

Set loading state when promise is set after click #12

merged 3 commits into from Jul 17, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jul 17, 2017

Loading state wasn't initialized if handleCurrentBtnOnly is true, and promise is added after click.

setTimeout(() => {
this.initLoadingState(btnEl);
}, 1);
});
Copy link
Author

@ghost ghost Jul 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced addEventListener with HostListener as the angular guide suggests.

It also fixes a memory leak, as the event listener wasn't detached when directive is destroyed.

Of course you could reach into the DOM with standard JavaScript and and attach event listeners manually. There are at least three problems with that approach:

You have to write the listeners correctly.
The code must detach the listener when the directive is destroyed to avoid memory leaks.
Talking to DOM API directly isn't a best practice.

@ghost
Copy link
Author

ghost commented Jul 17, 2017

@johannesjo could you please release a new version with all my changes? I use your module in several projects and I'd like to use the latest code :-)

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.7%) to 94.017% when pulling a6a802f on maxkorz:better-handleCurrentBtnOnly into feabf08 on johannesjo:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.726% when pulling 07fe442 on maxkorz:better-handleCurrentBtnOnly into feabf08 on johannesjo:master.

@johannesjo johannesjo merged commit cbeff3d into johannesjo:master Jul 17, 2017
@johannesjo
Copy link
Owner

Thanks again! I release a new version shortly.

@ghost
Copy link
Author

ghost commented Jul 17, 2017

My pleasure. If you have any kind of todo list of things you'd like to improve in your module, please share. Maybe I can help you with something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants