Skip to content

[labs/task] Tasks should run in hostUpdate(), not hostUpdate() #4003

@justinfagnani

Description

@justinfagnani

Which package(s) are affected?

Task (@lit-labs/task)

Description

Tasks need to update their host when run, so that the host can render the new pending state of the task.

If tasks are started in hostUpdated(), then a requestUpdate() call will trigger a double-render and associated warning. To work around the warning Task currently calls requestUpdate() in a microtask, but there is still a double-render.

We should instead run tasks in hostUpdate() and call requestUpdate() normally. The main observable difference with this timing is that host changes in update() are not visible to the Task in the current host update pass. State changes that should be visible to a task must be done in willUpdate which is run before hostUpdate().

Reproduction

n/a

Workaround

n/a

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

all

Browser/OS/Node environment

all

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions