You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I disagree with this - it's against the purpose of the isRunning method which by definition should return a boolean value. If anything, we should implement getByName method which will return the same TaskInfo object as get but for a provided name instead of taskId.
I even take it a step further, by making progress.info an object:
functionprogress({
current =undefined,
total =undefined,
info =undefined}={}){return_progress({
current,
total,info: info ? JSON.stringify(info) : undefined});}
And then using some info property to filter tasks on:
functiongetTasksWithRootId({
rootId,
name =TASK_NAME,
state
}){constrootTasks=listTasks({
name,
state
});//log.info(toStr({rootTasks}));consttasksWithRootId=rootTasks.filter((rootTask)=>{if(rootTask.progress.info){constinfo=JSON.parse(rootTask.progress.info);returninfo.rootId===rootId;}returnfalse;});//log.info(toStr({tasksWithRootId}));returntasksWithRootId;}
isRunning is not that magical. It does get list of running tasks and filters in by name and id.
It is also harmful, developers may think it is cheaper to call isRunning that to call list. But it is not true.
So, keep using list and apply your own filtering.
That way you don't have do use
to get the taskId in order to get progress.
ref: https://developer.mozilla.org/en-US/docs/Glossary/Truthy
The text was updated successfully, but these errors were encountered: