pub trait WithContext<App, Ef>where
    App: App,{
    // Required method
    fn new_with_context(
        context: ProtoContext<Ef, App::Event>
    ) -> App::Capabilities;
Expand description

Allows Crux to construct app’s set of required capabilities, providing context they can then use to request effects and dispatch events.

new_with_context is called by Crux and should return an instance of the app’s Capabilities type with all capabilities constructed with context passed in. Use Context::specialize to create an appropriate context instance with the effect constructor which should wrap the requested operations.

Note that this implementation can be generated by the derive macro Effect (in the crux_macros crate).

impl crux_core::WithContext<App, Effect> for Capabilities {
    fn new_with_context(
        context: crux_core::capability::ProtoContext<Effect, Event>,
    ) -> Capabilities {
        Capabilities {
            http: crux_http::Http::new(context.specialize(Effect::Http)),
            render: crux_core::render::Render::new(context.specialize(Effect::Render)),

Required Methods§


fn new_with_context(context: ProtoContext<Ef, App::Event>) -> App::Capabilities