We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It will be super helpful to have a monad-like syntax for Future. Here is something we are using for promises
Future
/** Resolve promise, requires to manually handle promise */ let (>>-) = (m: Js.Promise.t('a), f: 'a => Js.Promise.t('b)) => Js.Promise.then_(f, m); /** Resolve promise with auto return */ let (>>=) = (m: Js.Promise.t('a), f: 'a => 'b) => Js.Promise.then_(a => resolve(f(a)), m); let (>>|) = (m: Js.Promise.t('a), f: 'a => 'b) => Js.Promise.then_( a => { f(a); resolve(ignore); }, m, ); /** Catch promise */ let (>>/) = (m: Js.Promise.t('a), f: Js.Promise.error => Js.Promise.t('a)) => Js.Promise.catch(f, m); /** Catch promise with auto return */ let (>>/=) = (m: Js.Promise.t('a), f: Js.Promise.error => 'a) => Js.Promise.catch(e => Js.Promise.resolve(f(e)), m);
P.S. I could submit a PR for this if you don't mind. Thanks for the awesome work ;)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It will be super helpful to have a monad-like syntax for
Future
. Here is something we are using for promisesThe text was updated successfully, but these errors were encountered: