I am trying to figure out the best method of detecting a step change in Magento 2's checkout. For example going from shipping details to payment, or vice versa.
I have done some digging and in
vendor/magento/module-checkout/view/frontend/web/js/model/step-navigator.js I can use
next() which fires on the continue button, and
navigateTo() which fires when a user clicks on the checkoutstep directly - but both methods seem rather hacky, there must be a cleaner way to detect a step change regardless of how and which step.
I was hoping for a
stepChange() function or something similar that fires whenever a checkout step change happens.
What is the best method to trigger my custom JS when a checkout step change occurs?