#async #context #hook

nightly async-context

Provide context to async functions

2 releases

0.1.1 Jul 15, 2024
0.1.0 Jul 15, 2024

#181 in #hook


Used in 4 crates (via bloom-core)

MIT license

5KB
88 lines

A way to have some context within async functions. This can be used to implement React-like hooks.


async-content

This crate provides an easy way to provide context to async functions.

Use provide_async_context to provide the context:

provide_async_context(16, async {
    with_async_context(|my_number| {
        assert_eq!(my_number, 16);
    })
}).await

Dependencies

~190–610KB
~13K SLoC