Apply loader on “Select All” functionality of SumoSelect library

I am using sumoselect.js for my dropdowns. and i also have loader implemented in my project with id “mainloader”.

Now i want when user click on select all then loader should show i.e $(‘#mainloader’).show() and when sumoselect has selected all options inside dropdown then loader should removed i.e $(‘#mainloader’).hide().

But I am unable to implement this functionlaity. enter image description here

in sumoselect.js i have tried by adding my loader like below

enter image description here

but loader is showing after it is selecting all options but i want it should show instant when clicked on select and it should be hidden when all options are selected.