Controllong 'loading' attribute using js

Is there a way you can use js in a function to control the value of a the loading attribute. I can’t find any documentation on control whether or not a button is running the loading animation.

I found a solution by setting the :loading attribute to a variable and changeing that dynamically.