Compiler: better support for promise chains
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 23
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 17
Description
Did we miss a trick with promise chains? Should we be able to support an operation inside a .then callback?
We can currently do this:
each(
$.items,
post(`patient/${$.data.id}`, $.data).then(state => {
state.completed.push(state.data);
return state;
})
);
But surely it would be cool to support this?
each(
$.items,
get(`patient/${$.data.id}`)
.then(post(`patient/${$.data.id}`, $.data))
.then((state => {
console.log('done!')
return state
})
)
What I'm saying is that inside then() we should be able to write an operation, without a ()(state) wrapper.
Either compiler code, or some magic in promises (perhaps even a custom promise library), would have to "unwrap" the operation.
Something like this maybe?
each(
$.items,
get(`patient/${$.data.id}`)
.then((state) => post(`patient/state{state.data.id}`, state.data)(state))
.then((state => {
console.log('done!')
return state
})
)
But my feeling is:
.then()is called with state.then(get())will pass a function into .then(), which will be lazily executed- Can we extend
.then()to recognise that an Operation has been passed in, and handle it appropriately? I should have all the information it needs.
Contributor guide
No contributing guide indexed for this repository
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 tracing how the compiler and promise handling represent operations passed to .then(), using the examples in the issue as the behavioral reference. Determine whether direct operations can be recognized and lazily executed without the current ()(state) wrapper; done means promise chains support this form while preserving ordinary callback behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100