Questions tagged [fluture]

Fluture is a JavaScript library that offers a control structure similar to Futures in other languages. They are a lazy, Fantasy Land compliant alternative to JavaScript's Promises.

What is Fluture ?

From the official website:

Fluture offers a control structure similar to Promises, Tasks, Deferreds, and what-have-you. Let's call them Futures.

Much like Promises, Futures represent the value arising from the success or failure of an asynchronous operation (I/O). Though unlike Promises, Futures are lazy and adhere to the monadic interface.

Where can I get it?

You may find more information about the project in it's official git repository:

https://github.com/fluture-js/Fluture

16 questions
6
votes
2 answers

Use Fluture with Ramda

I was using Bluebird for doing asynchronous stuff, but now have to do a lot of empty / null / error checks and I don't want to go down the usual if Else route. Am thinking of using monads, but have not yet grokked it completely. Also I want it to…
jgr0
  • 697
  • 2
  • 6
  • 20
3
votes
2 answers

Convert Fluture Future to folktale Result

I have the following sample code to fetch a uuid: const Result = require('folktale/result') const Future = require('fluture') Future.prototype.flatMap = Future.prototype.chain const fetch = Future.encaseP(require('node-fetch')) const message = err…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
3
votes
1 answer

Can somebody tell me what is the difference between Task and Future concurrent action? Because the interface looks the same

// in using Task based on the fun-task library Task.create((res, rej) => res(5)).run({ success: console.log, failure: console.error }); // 5 // using Future through Fluture Future((reject, resolve) => res(5)).fork( console.error, …
Dennis Cual
  • 99
  • 1
  • 3
2
votes
1 answer

Railway Oriented Programming with Fluture

Railway Oriented Programming(ROP) is explained here: https://fsharpforfunandprofit.com/rop/ Is there any way to use this pattern with Fluture I can do ROP with these two helper methods like this: const bind = f => x => Future.attempt(() =>…
mohsen saremi
  • 685
  • 8
  • 22
2
votes
1 answer

How to log properly in Sanctuary / Fluture?

Background I have a function, called logInfoAsync. Let's consider this function sends some information to a log server over the network. For the purposes of this question let's assume the function is implemented as follows: const logInfoAsync =…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
1
vote
1 answer

What does it mean that in Fluture fork should be used in one place?

I was reading about Fluture, and one way to consume a Future is to call fork. That is all understandable so far but in documentation it states: "Generally, one only needs to call fork in a single place in the entire program". What does it mean? What…
Ansgar P.
  • 48
  • 5
1
vote
1 answer

Fluture: converting a future back to a promise for express global error handling

I am trying to find a way to convert a Promise to a future using the fluture library to implement functional programming, transform the data using a functional pipeline, then transform back to a promise so I can utilize await/async functionality. …
user1790300
  • 2,143
  • 10
  • 54
  • 123
1
vote
1 answer

Fluture: how should null handling get addressed using Monads

I am new to functional programming and I found the following fluture functional programming example that seems to give a really good example for handling database queries and subsequent data manipulation. The caveat however is that in reading about…
user1790300
  • 2,143
  • 10
  • 54
  • 123
1
vote
1 answer

Execute Fluture task in middle of Sanctuary pipe

I have a pipe like this: S.pipe([ getRequestFile, // not async S.chain(saveTemporary), // not async S.chain(copyImageToPublicPath), // async S.chain(copyFileToPath), // async …
1
vote
1 answer

UnhandledPromiseRejectionWarning when using Fluture `encaseP` on `fetch`

I have just started using Flutures, and I am trying to fetch some remote data for a visualization with d3. I created a function which accepts a DOM selector (e.g. #my-chart) and a url (e.g. https://example.com/data.json). If an error occurs when…
jackdbd
  • 4,583
  • 3
  • 26
  • 36
1
vote
2 answers

Fluture bimap and fold, what is the difference and when should I use them?

Background I am using Fluture to abstract Futures. Let's say I have a function that makes a GET request. This function can succeed or fail. Upon making a request, if it succeeds, it prints a message, if it fails, it logs the error and executes a…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
1
vote
2 answers

How to stub Fluture?

Background I am trying to convert a code snippet from good old Promises into something using Flutures and Sanctuary: https://codesandbox.io/embed/q3z3p17rpj?codemirror=1 Problem Now, usually, using Promises, I can uses a library like sinonjs to stub…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
0
votes
1 answer

Creating a composePipe function for Futures from Fluture

I wanted to make a compose function for piping and im stuck. I managed to make a pointfree pipe but cant figure out composing. // pointfree const pipe = fn => future => future.pipe(fn) // compose pipes // not working const composePipe = (...fns)…
Timar Ivo Batis
  • 1,861
  • 17
  • 21
0
votes
1 answer

how do I consume a future from a resolved fetch request?

I am using the coinbase dev API to access assets. To access rates data requires an access key which the API sends back from a POST request. I am using Flutures and a module called Fetch-Futures instead of just using the promise-based fetch API. I…
murpjack
  • 15
  • 5
0
votes
1 answer

execute Fluture task with Sancuary Either

I have a pipe like this const asyncFn = (x) => { return Future.tryP(() => Promise.resolve(x + ' str2')) }; const pipeResult = S.pipe([ x => S.Right(x + " str1"), // some validation function …
1
2