Add a way to enforce collection mutations via actions disallowing inline mutations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.9k
- Forks
- 266
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 55
Description
It would be great if we had a way to enforce only being able to use mutations like someCollection.insert inside of actions.
e.g.
This is allowed
const addTodo = createOptimisticAction<string>({
onMutate: (text) => {
todoCollection.insert({
id: uuid(),
text,
completed: false
})
},
....
})
This should be forbidden
<Button onClick={() =>
todoCollection.insert({
id: uuid(),
text,
completed: false
})}>
</Button
Why
The more I have used Tanstack DB the more I have realized almost all mutations I do have some sort of side effects, making single mutations quite useless. I started only using optimistic actions but coding agents and teammates often fall into the trap on using inline muations again. a way to enforce to enforce mutations through actions would be great
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 by reading the collection mutation APIs and optimistic action APIs referenced in the examples to understand where inline mutations and action mutations are distinguished. Done means there is an enforceable way to reject collection mutations outside actions while preserving mutations inside actions; the issue names no files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100