In this example we built a real estate site where the user can see properties up for sale and upload a property they would like to sell. We use wix-realtime-backend API to send real time notifications, so no matter on which page the user is on, they get a notification message once a new property has been added. The message includes the property’s neighbourhood and a link to the property's page.
How We Built It
Listings - holds the properties that are up for sale.
Amenities - holds the features of each property.
data.js - exports a afterInsert data hook on the Listings collection. This data hook uses wix-realtime-backend API to publish a message to the ‘new-property’ channel that a new property is up for sale, alongside a link to view that property.
Buy - a page that uses a repeater to display all the properties up for sale from the Listings collection. The page uses wix-realtime API and subscribes to the ‘new-property’ channel to get real time notifications. Once a message is published on that channel it runs the newPropertyUploaded function to display a message with the new property’s details for 10 seconds.
Upload - a page that lets the user upload a new property. It also subscribes to the ‘new-property’ channel to get and display a notification that a new property is up for sale.
Listings - a dynamic page that displays the details of each property.