FastLED 3.9.15
Loading...
Searching...
No Matches
promise.h File Reference

Detailed Description

Promise-based fluent API for FastLED - standalone async primitives.

The fl::task::Promise<T> API provides fluent .then() semantics that are intuitive and chainable for async operations in FastLED. This is a lightweight, standalone implementation that doesn't depend on fl::future.

Features

  • Fluent API: Chainable .then() and .catch_() methods
  • Non-Blocking: Perfect for setup() + loop() programming model
  • Lightweight: Standalone implementation without heavy dependencies
  • JavaScript-Like: Familiar Promise API patterns

Usage

// HTTP request with Promise-based API
fl::http_get("http://fastled.io")
.then([](const Response& resp) {
FL_WARN("Success: " << resp.text());
})
.catch_([](const Error& err) {
FL_WARN("Error: " << err.message());
});
#define FL_WARN(X)
Definition log.h:276

Definition in file promise.h.

#include "fl/stl/function.h"
#include "fl/stl/string.h"
#include "fl/stl/shared_ptr.h"
#include "fl/stl/move.h"
#include "fl/stl/atomic.h"
#include "fl/stl/noexcept.h"
+ Include dependency graph for promise.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fl::task::detail::PromiseImpl< T >
 Implementation class for Promise - holds the actual state and logic. More...
 
struct  fl::task::Error
 Error type for promises. More...
 
class  fl::task::Promise< T >
 Promise class that provides fluent .then() and .catch_() semantics This is a lightweight wrapper around a shared PromiseImpl for easy copying/sharing. More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::task
 
namespace  fl::task::detail
 

Enumerations

enum class  fl::task::detail::PromiseState_t { fl::task::detail::PENDING , fl::task::detail::RESOLVED , fl::task::detail::REJECTED }
 State enumeration for promises. More...
 

Functions

template<typename T>
Promise< T > fl::task::make_rejected_promise (const char *error_message) FL_NOEXCEPT
 Convenience function to create a rejected Promise (const char* overload)
 
template<typename T>
Promise< T > fl::task::make_rejected_promise (const fl::string &error_message) FL_NOEXCEPT
 Convenience function to create a rejected Promise.
 
template<typename T>
Promise< T > fl::task::make_resolved_promise (T value) FL_NOEXCEPT
 Convenience function to create a resolved Promise.