[task]: Add a "reset" method.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21.8k
- Forks
- 1.1k
- Avg merge
- 18h 25m
- Merged PRs (30d)
- 2
Description
Should this be an RFC?
- This is not a substantial change
Which package is this a feature request for?
Task (@lit/task)
Description
Use case:
I am implementing a form handler which, upon submission, fires off a task which may succeed or fail (using autoRun:false and calling run manually). Upon failure, I render whatever the appropriate error message is. If they start typing / modifying fields again, I'd like to immediately put the task back in the initial state.
I propose a reset() method that resets all internal state to the initial state.
Alternatives and Workarounds
I could certainly add state fields to the enclosing component to handle this, but then I've got to manage that state field and make sure I'm thinking through all the edge cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the @lit/task package and trace how manually run tasks transition between initial, success, and failure states. Add a reset entry point that returns all task state to initial, then verify it covers the form-handler case after a failed run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100