Connected to: https://github.com/DivanteLtd/vue-storefront/issues/3144
Hooks allow us to
afterPlaceOrder, afterAppInit (so called Listener hooks)beforePlaceOrder( order => { return modifiedOrder }) (so called Mutator hooks)I want to ask you (especially extension devs) what Listener/Mutator hooks you would like to see in Vue Storefront and why. For now we plan to add:
afterAppInit: listener - after modules and theme are registeredbeforeStoreViewChange(storeView): mutator- you can access/modify storeView object before changingafterStoreViewChange(storeView): mutator- you can access storeView object after changing storeViewbeforePlaceOrder(order): mutator - you can access/modify order object before sending order to backendafterPlaceOrder(order, task): listener - you can access order/task (order placement status) object after sending to backend I'm opening this issue to ask you what Hooks you want to have in VS along with new module system.
Looks great @filrak. OK, I'm adding my propositions:
beforeUserLogIn(credentials): mutator - to let devs implement other authorization workflow (can be done by overriding the login screen as wellafterUserAuthorized(userData): listener - once user get authorized the hook to bind to and to load custom data regarding current user account,afterUserLogOut(userData): listener,afterCartLoaded(cartItems): mutator,beforeCartSynced(clientItems): mutator - called in the cart/syncbeforeCartMerged(serverItems, clientItems): mutator - called in the cart/mergebeforeHydated(initialState):mutator - caleld before replaceState and before $mountMy request
afterCartUpdated(cartItems): listener - after items added / removed or quantity changed@grimasod could you please also tell a bit about use cases you see for those hooks?
@filrak Sure, I can think of a few
afterCartUpdated(cartItems): listener - example use cases:onAfterProductThumbnailPathGenerated(path, sizex, sizey): mutator - for integrating 3rd party services like Cloudinary,onBeforeTaxesCalculated(productList) - for integrating the 3rd party services like https://www.taxjar.com/ - it must work on kind of async/await Promises then @pkarw i believe for taxes it's much better to just override Vuex action responsible for calculating taxes, for images it's also not so straightforward. For example cloudinary (and probably many other services) uses it's own SDK with dedicated components so our thunb helpers might be useless anyway. Also hook should work as an extension of current behavior, not it's replacement
@filrak OK
@grimasod that looks like something that can be achieved through mutation subscription
@filrak is there a list of already implemented hooks? I'm not sure if we already have cart hooks, I als ocreated a product hooks ticket