async(.promise) and promises (docs still accurate?)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Documentazione
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- swift
- Ambito
- api, documentation
Direzione di ricerca
Start with the Appendix passage and reproduce the reported async(.promise) examples using the current Swift and PromiseKit behavior. Determine whether the documentation is still accurate and whether Promise or Guarantee results are unwrapped; done means a documented conclusion, with any required API or documentation scope identified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
There's a blurb at the end of the Appendix document that reads:
So, if you want to start a chain by dispatching to the background, you have to use
DispatchQueue.async:DispatchQueue.global().async(.promise) { return value }.done { value in //… }However, this function cannot return a promise because of Swift compiler ambiguity
issues. Thus, if you must start a promise on a background queue, you need to
do something like this:Promise { seal in DispatchQueue.global().async { seal(value) } }.done { value in //… }Or more simply (though with caveats; see the documentation for
wait):DispatchQueue.global().async(.promise) { return try fetch().wait() }.done { value in //… }However, you shouldn't need to do this often. If you find yourself wanting to use
this technique, perhaps you should instead modify the code forfetchto make it do
its work on a background thread.
I wasn't sure of the exact issue behind this caution, so I spent some time trying to reproduce it, without much luck. Is it possible that current compilers handle this situation more smoothly?
E.g., this seems to work fine:
DispatchQueue.global().async(.promise) {
return Promise.value(42)
}.then {$0}.done { value in
print(value)
}.catch { _ in }
If the situation is in fact better now, it might be nice if the async(.promise) family provided its own unwrapping when the return type of the closure was a Promise or Guarantee so that, e.g., the return type of
queue.async(.promise) { Promise.value(42) }
would be Promise<Int> rather than Promise<Promise<Int>>.
It's potentially a breaking change, but since the docs have historically warned away from this, maybe not a big deal for PMK7?
- Lingua principale
- Swift
- Stelle
- 14.2k
- Fork
- 1.5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 mxcl/PromiseKit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
mxcl/PromiseKit#1362 · 1 commento · 1 reazione ·
-
CocoaPods supportAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
mxcl/PromiseKit#1361 · 6 commenti · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
mxcl/PromiseKit#1356 · 3 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
mxcl/PromiseKit#1347 · 5 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
mxcl/PromiseKit#1244 · 1 commento · 1 reazione ·
Tutte le issue di mxcl/PromiseKit
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
Countly/countly-sdk-ios#485 ·
I maintainer di solito rispondono entro 1 giorno
-
area:ui enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
s3onghyun/bulchimbeon#22 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
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
-
[BUG] File transcription skips audio chunks shorter than one secondForse già presa @sabbah13 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
altic-dev/FluidVoice#1161 ·
I maintainer di solito rispondono entro 1 giorno