Notify progress

How can one notify progress in a function?

By that I mean something like this:

  async 'importantwork'(postBackToClient) {
    // announce to client that we are about to work on something
    postBackToClient('gathering stuff')
    let data = await doLotsOfAdvancedStuff()
    // announce to client that we have finished with part 1, and begin a new thing
    postBackToClient('working on the stuff')
    let result = await doLotsOfOtherAdvancedStuff(data)
    return result

In a perfect world, the postBackToClient function notifies the specific client calling the method of its progress, and the last returned result would be the last answer the client receives, and ultimately the winning result. Other messages would be discarded and result should win.

One of the solutions would obviously be storing progress in a collection, but forcing temporary through the database seems like it would kill scaling.

Sorry if this is some noob question, but I have a really hard time grasping DDP.

I’m using this package gfk:notifications for notifications from client and server side.