Thanks to visit codestin.com
Credit goes to lib.rs

#async #hook #provide-async-context

nightly async-context

Provide context to async functions

2 releases

0.1.1 Jul 15, 2024
0.1.0 Jul 15, 2024

#139 in #hook

43 downloads per month
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

~225–660KB
~14K SLoC