I need an explanation on how to set up frappe to use frappe.publish_realtime

I have a background task that’s triggered onclick of a button.
I want to get the progress of the task and display in doctype listview.

please help with an example.