progress-stream icon indicating copy to clipboard operation
progress-stream copied to clipboard

`update` object is reused for all events?..

Open busticated opened this issue 7 years ago • 1 comments

hey there :wave:

thanks for the helpful module :pray:

i assume this was done on purpose but i'd be curious about the rationale - the update object is mutated in-place and emitted in its current state with each progress event (source).

this threw me a bit as i was hanging on to these objects in my tests only to discover that once an operation had completed i just had a bunch of references to the same object, all reflecting the final state (e.g. percentage: 100).

busticated avatar Mar 14 '19 21:03 busticated

@busticated Sorry for the late reply. I can't exactly remember the reasoning behind it. But as the module would potentially emit very often, reusing the object could be an optimisation compared to creating a new object before every emit (I am not sure if this was the case, nor am I sure if this is still valid). Whether or not that was my reasoning back then I am not too sure.

freeall avatar May 07 '19 12:05 freeall