Show progress of server method on client side


#1

I want to show the progress of a long-running server method on the client side. Is there a way to send some data back to the client while a server method is still running?


#2

Just an idea.

You could subscribe to a collection, say ProgressReport, and just update it in your method call whenever needed.

What do you think?


#3

Thanks for answering. Yes, this should work, but to be honest, I think this is a rather “hacky” way to do it. Polluting the database with performance indication data just feels a bit strange to me. I was rather thinking about a way to use the DDP connection that the Meteor method is being called with with for sending intermediate results, but I don’t know if this is even possible?!


#4

What about using the Event emitter package, and listening to a custom progress event related to the userId?
https://atmospherejs.com/raix/eventemitter


#5

That sounds interesting, did not know it. Will this also work across the client-server boundary? The examples seem to illustrate how to use it on one side of the fence only.


#6

Yeah, you’re right. I meant this package:
https://atmospherejs.com/raix/eventddp


#7

Aaah, that looks much more like it :smile: Thanks!


#8

Or you can probably cook something with https://meteorhacks.com/introducing-meteor-streams
With looong running tasks I would think of persisting it in DB so you can logout/relog etc and still be able to track it tho. When method would just start something and report back to client with just info if task was inicialized.


#9

I don’t think that package is maintained anymore, though :frowning: But it was a good project.


#10

Well, maybe package is not extra up2date, but principles how to manage something like that over DDP without involving database stay quite stable over time.