Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jupyter): Await return from Jupyter.display #20807

Merged
merged 4 commits into from
Oct 6, 2023

Conversation

manzt
Copy link
Contributor

@manzt manzt commented Oct 5, 2023

Allows Jupyter.display to return a promise.

Silly example:

class WikiPage {
    constructor(public name) {}
    async [Symbol.for("Jupyter.display")]() {
        let response = await fetch("https://en.wikipedia.org/wiki/" + this.name);
        return { "text/html": await response.text() }
    }
}

new WikiPage("Deno_(software)")
image

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, can you update the integration test notebook to showcase that async functions are supported as well? You add add a promise that resolves after 100ms and only then provides an output.

@manzt
Copy link
Contributor Author

manzt commented Oct 5, 2023

Cool, can you update the integration test notebook to showcase that async functions are supported as well? You add add a promise that resolves after 100ms and only then provides an output.

Done!

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @manzt!

@bartlomieju bartlomieju enabled auto-merge (squash) October 6, 2023 20:29
@bartlomieju bartlomieju disabled auto-merge October 6, 2023 20:29
@bartlomieju bartlomieju enabled auto-merge (squash) October 6, 2023 20:30
@bartlomieju bartlomieju merged commit 48bb3b2 into denoland:main Oct 6, 2023
@rgbkrk
Copy link
Contributor

rgbkrk commented Oct 7, 2023

Thanks @manzt and @bartlomieju!

I made a display release that adapts to async displayables. https://github.com/rgbkrk/display.js/releases/tag/v1.1.0

bartlomieju pushed a commit that referenced this pull request Oct 12, 2023
Allows `Jupyter.display` to return a promise.

Example:

```javascript
class WikiPage {
    constructor(public name) {}
    async [Symbol.for("Jupyter.display")]() {
        let response = await fetch("https://en.wikipedia.org/wiki/" + this.name);
        return { "text/html": await response.text() }
    }
}

new WikiPage("Deno_(software)")
```
@manzt manzt deleted the manzt/await-jupyter-display branch March 19, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants