rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
201 stars 19 forks source link

then et al support implicit conversion of objects to promises #2

Closed jcheng5 closed 6 years ago

jcheng5 commented 7 years ago

future::Future support is built in.

With this PR, you can seamlessly treat regular future() results as promises.

library(promises)
library(future)
plan(multicore)
future({Sys.sleep(1); cars}) %...>% head() %...>% print()

An unsolved problem is that contexts that can take either promises or non-promises (like Shiny render functions) would have no way to know whether to attempt converting something to a promise or not.

jcheng5 commented 7 years ago

Might also be helpful for docs to point out that this is not how you take a result value and turn it into a promise (like $q.when(valueOrPromise)). Instead, that is promise(~resolve(valueOrPromise)).

jcheng5 commented 7 years ago

Almost forgot, this PR also includes promise_lapply utility function.