|
libkazv
|
A Promise represents an asynchronous result that can be fetched later. More...
#include <promise.hpp>
Public Types | |
| using | DataT = T |
| The type of the value this Promise will hold. More... | |
Public Member Functions | |
| template<class Func > | |
| Promise | then (Func &&f) |
| Specify something to do after this Promise resolves. More... | |
A Promise represents an asynchronous result that can be fetched later.
A Promise is called resolved when the result becomes available.
In libkazv docs, the result type is usually EffectStatus.
Specify something to do after this Promise resolves.
| f | the function to run. It should take a DataT as the only argument. |
result is the result this Promise resolves to. If f(result) returns void, it resolves to DataT() after f returns. If f(result) returns a Promise, it resolves to what the Promise will resolve to, after that Promise resolves. Otherwise it resolves to what f(result) returns, implicitly converted to DataT, after that function returns.