Spaces:
Running
Running
File size: 393 Bytes
8f3f8db |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
promises
await: promise
"Pause the current process until promise returns, signal an exception if the promise was rejected"
| sem result isError |
isError := false.
sem := Semaphore new.
promise
then: [:value |
result := value.
sem signal];
catch: [:error |
result := error.
isError := true.
sem signal].
sem wait.
isError ifTrue: [JSException error: result].
^result |