re: Pro tip: using Promise.then for function composition VIEW POST

VIEW FULL DISCUSSION

The only issue I see here is that promise is always asynchronous and using then for function chaining might compromise shared data.

I'm not sure I understand you. Could you give an example of what you mean by "compromising shared data"?

I mean that each time you chain a function using then that function is added to the queue which means that it will wait for at least a tick to be called, my only concern is if during that tick a variable, that one of the callbacks relies on, is modified. Maybe is not a pressing matter, just a concern I have.

Nice post tho.

@Pichardo Promises resolve only once, and their value is immutable. And in a functional promise chains each step results in a read-only state.

code of conduct - report abuse