Generators.observe needs a better way to throw? (And end?)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- api
Direzione di ricerca
The issue does not name an implementation file or test. Start by locating the current Generators.observe implementation and compare its behavior with the linked Observable proposal. Done requires a decided API for repeated values, errors, and normal completion, followed by corresponding tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
It’s possible if you notify with a rejected Promise, but this seems a little awkward. For example:
Generators.observe(notify => {
const socket = new WebSocket("wss://ws.blockchain.info/inv");
socket.onerror = () => notify(Promise.reject(new Error("socket error")));
socket.onopen = () => socket.send(JSON.stringify({op: "unconfirmed_sub"}));
socket.onmessage = event => notify(JSON.parse(event.data));
return () => socket.close();
})
We could pass two callbacks, resolve and reject, instead (or next and error for symmetry with the Observable proposal; maybe it would be confusing to use the name resolve when it can be called repeatedly)?
Generators.observe((resolve, reject) => {
const socket = new WebSocket("wss://ws.blockchain.info/inv");
socket.onerror = () => reject(new Error("socket error"));
socket.onopen = () => socket.send(JSON.stringify({op: "unconfirmed_sub"}));
socket.onmessage = event => resolve(JSON.parse(event.data));
return () => socket.close();
})
But even then we don’t have a way to indicate that the observable stream has ended (without an error). That would correspond to the observer.complete method. If we passed an observer in instead, that would look like:
Generators.observe(observer => {
const socket = new WebSocket("wss://ws.blockchain.info/inv");
socket.onerror = () => observer.error(new Error("socket error"));
socket.onopen = () => socket.send(JSON.stringify({op: "unconfirmed_sub"}));
socket.onmessage = event => observer.next(JSON.parse(event.data));
return () => socket.close();
})
- Lingua principale
- JavaScript
- Stelle
- 1k
- Fork
- 87
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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 observablehq/stdlib
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
observablehq/stdlib#397 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
observablehq/stdlib#384 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
observablehq/stdlib#379 · 1 commento ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
observablehq/stdlib#378 · 2 commenti · 2 reazioni ·
-
issue with DuckDB parsingAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
observablehq/stdlib#371 ·
Tutte le issue di observablehq/stdlib
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
tshemsedinov/reslop#158 ·
I maintainer di solito rispondono entro 1 giorno
-
level/task type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
wazuh/wazuh-documentation#10398 ·
I maintainer di solito rispondono entro 1 giorno
-
app_installations reports an error on every repo or suborg change when the plugin is not configuredAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
github-community-projects/safe-settings#1111 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno