scalajs-io / nodejs

This project provides Scala.js type-safe bindings for Node.js (current) v8.7.0 and LTS v6.11.4 APIs. The platform supports MEAN (MongoDB, Express, AngularJs, NodeJS), Cassandra, MySQL and many other npm projects.
Apache License 2.0
163 stars 28 forks source link

fs *Async return Promise instead of Future #14

Closed aappddeevv closed 7 years ago

aappddeevv commented 7 years ago

I noticed that the fs *Async functions all return scala Promises vs Futures. Since I always need to compose these, why not return Future in the API since its not node.js standard anyway? The completion is always handled within the function so there never really is anything you can do with it. I know its just a aPromse.future to get the Future but you cannot do much with the returned promise as is. Was there a reason for returning a scala Promise?

scalajs-io commented 7 years ago

Just do this, and it automatically lifts all of the Promise[T]'s to Future[T]'s

import io.scalajs.util.PromiseHelper.Implicits._
sjrd commented 7 years ago

I agree with @aappddeevv. In Scala, a Promise is an implementation detail, and should never be seen in a public signature. The normal result type is Future.

scalajs-io commented 7 years ago

I'll change this in version v0.4.0-pre5. Should have a new release by Monday or Tuesday night.

ldaniels528 commented 7 years ago

Fixed in release v0.4.0-pre5