Almost all of the buttons in my angular 4 app have asynchronous operations associated with them. I'm currently adding a loading spinner to each button manually whenever the button is clicked, and removing it when the operation concludes.
I've realized too late that I could have saved myself a lot of time refactoring etc, if I simply had a custom button component that took an asynchronous event handler and added/removed the spinner on its own.
I'm relatively new to angular 2+ and I'm wondering what a good approach to solving this would be. Should I do a custom component? Or just a custom directive? How do I require the clients of such a component/directive to provide me an asynchronous event handler? Do I use custom attributes or some kind of wrapping around the normal event handling?
I'm not asking for code, just the right features to use, I can take it from there.
Edit:
The loading spinner functionality is currently implemented for each button by showing/hiding an icon element via a boolean property in the corresponding component.