Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[labs/task] Initial pending templateΒ #3143

@a11delavar

Description

@a11delavar

Which package is this a feature request for?

Task (@lit-labs/task)

Description

I find myself not using lit's Task in most cases because there is no way of rendering a template only for the initial pending state. It would be a helpful addition to have this baked into Task itself, as the current implementation does not allow much tweaking.

This way you can for instance render a loading screen and then render an expensive template when the value is resolved, but not go back to the pending state if you were to rerun the Task for whatever reason, which leads to reconstructing the expensive template to have the pending template in between.

Alternatives and Workarounds

I considered deriving the Task class to add this option, as well as using Task without its render and handle its value by myself, but both won't work as the underlying _value also gets destroyed when run is called. https://github.com/lit/lit/blob/main/packages/labs/task/src/task.ts#L199-L203

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