2
56%
MIT
Future and ResultFuture library for ReasonML

re-future

npm version Build Status Coverage Status Known Vulnerabilities

ReasonML library to provide Future and ResultFuture monads as an alternative to Js.Promise.

The Future is the most simple unit of evaluable value which can resolve at some point in the future. ResultFuture is a future that eventually contains Belt.Result.t result inside. This is the most useful replacement for Js.Promise because Js.Promise also contains the possibility of resolving to Ok value or rejection to Error value.

Special focus has been given to provide complete and yet compact set of utility functions to work with both Future and ResultFuture entities. Besides test coverage this library also contains a very basic memory performance test to ensure that memory gets freed (garbage collected) when Future has used the binded functions and evaluation is done.

Install

npm install @rejs/re-future

Edit to bsconfig.json:

"bs-dependencies": [..., "@rejs/re-future", ...],

This library is namespaced; to simplify access do:

  • RE
  • ML
module ResultFuture = RejsReFuture.ResultFuture;
// or
open RejsReFuture;
2553: <UNKNOWN SYNTAX ERROR>

Or you can open globally in your bsconfig.json:

"bsc-flags": [ "-open RejsReFuture" ]

SDK Documentation and Examples

More usage examples also in the __tests__/

The most compact references of Future and ResultFuture are the interface files: