Created
August 22, 2024 13:56
-
-
Save psychemedia/fccd80cfb6c451ffbab83fbdcc0dcaf1 to your computer and use it in GitHub Desktop.
Demo async p5/js notebook demo of async function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"kernelspec": { | |
"name": "p5js", | |
"display_name": "p5.js", | |
"language": "javascript" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "javascript" | |
}, | |
"file_extension": ".js", | |
"mimetype": "text/javascript", | |
"name": "p5js", | |
"nbconvert_exporter": "javascript", | |
"pygments_lexer": "javascript", | |
"version": "es2017" | |
} | |
}, | |
"nbformat_minor": 4, | |
"nbformat": 4, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"source": "# Some stuff...\n\nabout whatever...\n\nHere's an example:", | |
"metadata": {} | |
}, | |
{ | |
"cell_type": "code", | |
"source": "async function example() {\n\n let promise = new Promise((resolve, reject) => {\n setTimeout(() => resolve(\"The promise has resolbved aftaer a delay!\"), 3000)\n });\n\n let result = await promise; // wait until the promise resolves (*)\n\n alert(result); // \"done!\"\n}\n\nexample()", | |
"metadata": { | |
"trusted": true | |
}, | |
"outputs": [ | |
{ | |
"execution_count": 11, | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": {} | |
}, | |
"metadata": {} | |
} | |
], | |
"execution_count": 11 | |
}, | |
{ | |
"cell_type": "code", | |
"source": "", | |
"metadata": { | |
"trusted": true | |
}, | |
"outputs": [], | |
"execution_count": null | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment