n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.19k stars 185 forks source link

Proposal: Improve $$async$$ and $$done$$ api with promises #115

Closed thalesmello closed 7 years ago

thalesmello commented 7 years ago

Every time the returned object is a promise, I propose we wait the promise to complete before fetching the result by default.

For example, instead of:

$$async$$ = true
var { promisify } = require('util')
var delay = promisify(setTimeout)

delay(1000)
  .then(() => $$svg$$ = "<svg><circle cx='30px' cy='30px' r='20px'/></svg>")
  .then(() => $$done$$())

We could have:

var { promisify } = require('util')
var delay = promisify(setTimeout)

delay(1000)
  .then(() => $$svg$$ = "<svg><circle cx='30px' cy='30px' r='20px'/></svg>")

The idea is that we would have it await by default.

What do you think?

n-riesco commented 7 years ago

I'm tracking this issue in the repository for the NEL package. See this issue.

I'm about to publish an update that implements display_data. I'll work on Promises in outputs next.

I'm closing this issue. Please, continue the discussion in the NEL issue.