Replies: 1 comment
-
I found a workaround, I can instantiate the service inside create, and access this field in other functions, like: fn create(_ctx: &Context<Self>) -> Self {
Model {
service: SuperDuperService::new("super duper secret key")
}
}
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
match msg {
Msg::Connect => {
self.service.connect(
"super-duper-service",
);
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a service that I want to use inside a component, and I am trying to figure out how to pass this service at the moment of instantiating. So, basically, I want to do something like:
and inside the component, something like:
However, it raises the following exception:
I want to use this context inside the component, but I am not sure how, Is this thing possible?
Edit-1: How to programmatically communicate with this component so that I can access
ctx
?Edit-2: I have found something similar In the
two_apps
example. I will try it out.Edit-3: I am looking for something similar, like
with_context
or some.Beta Was this translation helpful? Give feedback.
All reactions