let%Everything ReasonML

posted on 08 December 2019

let%Anything is a really cool module for ReasonML,

Which allows you to create a module and use as with let%Module, lets take a look how to use.

Since buckleScript have upgraded to 7++ by default and I am using bs-let for demo:

Create a module and method that you like, with let_.

Here I create a very basic module of MapEmpty with let_, that takes a parameter and returns a callback which will be used as promise.

So we can use this module as %Module

You can find very cool introduction on EggHead of how you can use with async/await to replace promise in ReasonML.

Although EggHead is using promise from got module, I like to use bs-fetch so that you don’t have to write binding. Lets install bs-fetch

And remember to add bs-fetch to your bsconfig file

Now we want to create a Fetch module that will call a ajax and return the json data

and create the async method

so now you can use it like the way you want like Javascript async/await