For your first question:
Yes you can use data hooks to listen to changes to collections but not for collections associated with Wix Stores. Why not use the events that wix-stores-backend provides?
For the second one:
With Wix Stores you’ll need to use the Wix Stores events. You cannot use data hooks on a Collection that is related to Wix Stores. You can use data hooks on any Collection that you make yourself.
Regardless of where your backend events/hooks are you can do the following to pass information back to the client without refreshing the page:
-
The wix-realtime-backend API to send messages and listen to those messages in the frontend with wix-realtime API.
-
Creating a Collection with the data you want and having the client regularly query it:
// query every second then do something
setInterval(() => {wixData.query("yourCollection").eq("someColumn", "myData").find()}, 1000).then( (results) => {//do something})
Note in both of these they aren’t true “events” in that they don’t happen exactly when the trigger happens but should generally be good enough.