Skip to content

4.0.0

Compare
Choose a tag to compare
@Avaq Avaq released this 29 Oct 12:23
· 931 commits to master since this release

Compare 3.1.1...4.0.0

⚠️ Breaking changes (see upgrading below)

  • Future.recur has been removed in favor of Future.chainRec.
  • #38 Future.ap is no longer parallel. Instead one might use Future.and or Future.both.
  • #38 of and fantasy-land/chainRec are no longer available on the prototype.

New features

  • #34 Casting a Future to string now shows a much more friendly representation.
  • #39 Future.rejectAfter has been added as a counterpart to Future.after.
  • #40 Future.and has been added as a counterpart to Future.or.
  • #41 Future.both has been added as an alias to Future.parallel(2, [a, b]).
  • #42 Static ap, map, bimap and chain functions can now handle native
    algebraic data types, courtesy of sanctuary-type-classes.

🐛 Bug fixes and improvements

  • #4 Several curried functions have been made to fail the moment they receive an invalid argument.
  • #34 When a cached Future is cancelled, its other subscribers are not unsubscribed.
  • #34 When a hooked Future is cancelled, the disposal Future is still forked (and cancelled).
  • #34 Some Futures were not being automatically cancelled when no longer needed.
  • #42 Improved string representations of values in error messages, courtesy of
    sanctuary-type-classes.

🚀 Performance

  • #34 Performance of Future.race has trippled.
  • #34 Performance of Future.cache has doubled.
  • #34 Performance of Future.chainRec has improved by 50%.
  • #34 Performance of Future.parallel has improved by 30%.
  • #34 Performance of all other functions has improved by 10%-20%.

⬆️ Upgrading

Refactor code using Future.recur into code using Future.chainRec

const repeat = (x) => Future.after(10, x).map(add(1)).recur(repeat);
repeat(1).fork(...)
  • becomes
Future.chainRec((next, done, x) => Future.after(10, x).map(add(1)).map(next), 1)
.fork(...)

Use Future.both over Future.ap for parallelism

Future.of(1).ap(Future.of(add(1)))
  • becomes
Future.of(1).both(Future.of(add(1))).map(([x, f]) => f(x))

Use Future.parallel(Infinity) over sequence(Future.of)

sequence(Future.of, [m1, m2, m3])
  • becomes
Future.parallel(Infinity, [m1, m2, m3])

Access of via constructor property

const empty = m => m.of()
  • becomes
const empty = m => m.constructor.of()