libkazv
Promise< T > Class Template Reference

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...
 

Detailed Description

template<class T>
class Promise< T >

A Promise represents an asynchronous result that can be fetched later.

Warning
This is an interface, not an actual class in the library.

A Promise is called resolved when the result becomes available.

In libkazv docs, the result type is usually EffectStatus.

Member Typedef Documentation

◆ DataT

template<class T >
using Promise< T >::DataT = T

The type of the value this Promise will hold.

Member Function Documentation

◆ then()

template<class T >
template<class Func >
Promise Promise< T >::then ( Func &&  f)

Specify something to do after this Promise resolves.

Parameters
fthe function to run. It should take a DataT as the only argument.
Returns
A Promise. Assume 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.

The documentation for this class was generated from the following file: