New Js Example: Top level await implementation for modern Browsers
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, wasm
- Ambito
- documentation
Direzione di ricerca
Start with examples/javascript/index.html and the linked top-level-await references. Compare the current promise-based example with the supplied HTML example, then document the modern-browser variant and verify it in the Puppeteer setup described. Done means the example is readable, works with the RDKit WASM module, and is included in the documentation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I've been struggling to get running the javascript example on the documentation.
As it is well known, since ES2022, we can use top level await in javascript modules.
I can confirm that below example works.
✅ Tested on PDF generation HTML template with Puppeteer, run in NodeJS application.
<head>
<!-- ...other files and HTML tags... -->
<!-- Load the RDKit JS file -->
<script src="https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.js"></script>
<!-- Instantiate the WASM module. The inline script below could live elsewhere inside your application code. -->
<script type="module">
const RDKitModule = await initRDKitModule(); // <-- Top level await
const smiles = "CC(=O)Oc1ccccc1C(=O)O";
const mol = RDKitModule.get_mol(smiles);
const svg = mol.get_svg();
console.log(svg);
</script>
<!-- ...your application code goes here... -->
</head>
Conclusion
After all, I got the proposed js example working. I just moved all my javascript code inside the .then statement.
Yeap, it works, but looks very messy and decreases readability.
Since most of the users are running modern browsers and my team works only with >=ES6, I really wanted that juicy syntactic sugar 🍭
I suggest adding the above example in the docs?
what do you say @MichelML
- Lingua principale
- SCSS
- Stelle
- 248
- Fork
- 47
- Merge medio
- 4m
- PR unite (30g)
- 4
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rdkit/rdkit-js
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Tutte le issue di rdkit/rdkit-js
Issue simili
-
agent-ready documentation needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
dotnet/dotnet-api-docs#13095 ·
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100