#Add a way to know when a collector with idle will end

14 messages · Page 1 of 1 (latest)

steady kettle
#

Currently there is no way to tell when a collector with an idle option will end and afaik there is no way to get that information from the timeout itself (there is but it involves using _idleStart and process.uptime() which I don't think is ideal). I also thought about adding a getter that returns the createdTimestamp of the last collected item like @indigo geode suggested but, since collectors are agnostic to what they're collecting, we can't really assume that will always be a thing. The only other alternative I can think of is storing a property of the last timestamp something was collected at in the class itself. Any other suggestions/anyone against this?

indigo geode
#

Set <Collector>.lastCollectedTimestamp = Date.now() in handleCollect

steady kettle
#

yes I know how to do it, I'm just making this post to see if anyone is against storing that timestamp there or if there would be other alternatives

green heron
#

What's the use case for this, being able to show a timer for how long it'll still collect or something?

steady kettle
green heron
#

ahh right

covert yoke
steady kettle
covert yoke
steady kettle
covert yoke
steady kettle
#

In that case yes but I have other cases with more interactions in the way in which the timer would be less than the idle timeout

covert yoke
#

But then you do have both collectors available in that scope… so you can add an end event handler stopping the other one just fine there, can’t you?

steady kettle
#

Not quite because I’m using the await methods not actual collectors