|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
Driver that turns a coroutine factory into a latest-wins async validation rule attached to a Validator<T>. More...
#include <async_validator.hpp>
Public Types | |
| using | Factory = typename detail::AsyncValidatorState<T>::Factory |
Public Member Functions | |
| AsyncValidator (IExecutor &ui, IExecutor &worker, Factory factory) | |
| ~AsyncValidator () | |
| AsyncValidator (const AsyncValidator &)=delete | |
| AsyncValidator & | operator= (const AsyncValidator &)=delete |
| AsyncValidator (AsyncValidator &&) noexcept=default | |
| AsyncValidator & | operator= (AsyncValidator &&other) noexcept |
| ::aria::Subscription | attach_to (::aria::Validator< T > &v, ::aria::Property< T > &source) |
| Attach to a Validator + its source Property. | |
Driver that turns a coroutine factory into a latest-wins async validation rule attached to a Validator<T>.
Typical usage:
AsyncValidator<std::string> av{
ui_executor, worker_pool,
[&](std::string username, CancellationToken tok)
-> Task<AsyncRuleResult> {
tok.throw_if_cancelled();
bool taken = co_await api.check_username(username);
tok.throw_if_cancelled();
if (taken) {
co_return AsyncRuleResult::failed(
ValidationKey{"signup.username", "remote_taken"},
"Username already taken");
}
co_return AsyncRuleResult::passed();
}};
Subscription sub = av.attach_to(validator, source_property);
On every change of source_property the AsyncValidator cancels the previous rule, fires a new one, and surfaces the result via validator.begin_pending() / end_pending(...). Attach, detach, move assignment and destruction run on the graph thread. Both executors must outlive their queued coroutine work.
| using aria::async::AsyncValidator< T >::Factory = typename detail::AsyncValidatorState<T>::Factory |
|
inline |
|
inline |
|
delete |
|
defaultnoexcept |
|
delete |
|
inlinenoexcept |
|
inlinenodiscard |
Attach to a Validator + its source Property.
The returned Subscription owns the lifetime: destroying it detaches the validator and cancels any in-flight rule (V-6).