How to create generator function
In the documentation I have noticed that we can use promise to handle asynchronous request. AFAIK, I assume that yield is not useable in Rescript context. However, in redux-saga we have to use functions with an asterisk besides it. For example,
function* mySaga() {
yield takeEvery("USER_FETCH_REQUESTED", fetchUser);
}
function* mySaga() {
yield takeLatest("USER_FETCH_REQUESTED", fetchUser);
}
So for Rescript how can I write that out then?
Unfortunately ReScript doesn't semantically support generators. You'd probably need to write your generators logic as plain JS / raw expressions.
bummer :-(
to be fair, the idea of redux-saga doesn't really find any good use-case in ReScript (beside interop), since the language itself offers enough facilities to express complex state machines. I've used sagas a lot myself back then and have seen it in a handful of codebases,... but never had a need for it ever since I've used ReScript & React hooks.
I will close this for now, since this question usually would go to the forum