Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

[Discuss]should onHasTask being notified by periodMacroTask #1017

@JiaLiPassion

Description

@JiaLiPassion

based on #999, current setInterval 's behavior is

  • when call setInterval will schedule a macroTask with isPeriodic=true, and trigger onHasTask with macroTask count +1.
  • and when interval callback is invoked, onHasTask will not be invoked because it is periodic.
  • when cancelInterval is called, will trigger onHasTask with macroTask count -1.

It is the correct behavior.

But in onHasTask callback, we can only get

type HasTaskState = {
  microTask: boolean; macroTask: boolean; eventTask: boolean; change: TaskType;
};

macroTask is true or false, but we can not get whether the macroTask isPeriodic or not.
In some case, we may want to consider

  • all microTasks
  • all non-periodic macroTasks

are stable.

For example, in some application, we start a interval to polling from server at background, and basically we should ignore this interval task when we want to check the application is stable or not. otherwise the application will not stable at all.

@mhevery , do you think we need to provide something like

type HasTaskState = {
  microTask: boolean; 
  macroTask: boolean; 
  eventTask: boolean;
  change: TaskType;
  isAllMacroTasksPeriodic: boolean;
};

to provide isPeriodic information and not making breaking changes?

Please review, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions