4 ms·
> A stateful function with effects. Your language just doesn’t have a primitive to express it. I wonder what about generator functions?
by traderjane 6y ago
> A stateful function with effects. Your language just doesn’t have a primitive to express it.
I wonder what about generator functions?
- lhorie 6y agoYep, there was even a library making the rounds recently that leverages them: https://crank.js.org/ https://crank.js.org/
- hombre_fatal 6y agoAnother example: Redux Saga has been using them in React for a long time. https://redux-saga.js.org/ https://redux-saga.js.org/
- dcre 6y agoI don't see how generators would change anything here. "with effects", "stateful", and the integration between the two are all equally important in the statement.
- williamdclt 6y agoWell generators are a good primitive to represent "stateful" "functions" "with effects". The concept of hooks, which somehow give the control back to React to do something, map marvelously to react. I'd be surprised if generators didn't come into React at one point or another
- orange8 6y agoThere are two different concepts as I see it, please correct me if your definitions differ. "stateful": A function that has state, i.e. can store data "with effects": A function that modifies data outside its own scope Normal JS functions (as opposed to arrow function) already do this: function foo(){}; foo.state = bar; Generator functions take it a step further, where the function remembers internal state between calls.
- traderjane 6y agoWhat are generators for you?