Skip to content

Commit

Permalink
remove the Clone of WorkerProviderState
Browse files Browse the repository at this point in the history
  • Loading branch information
deftsp committed Oct 2, 2023
1 parent 5f546ea commit 96649bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/yew-agent/src/scope_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
W: Worker + 'static,
{
let inner = self
.context::<WorkerProviderState<W>>((|_| {}).into())
.context::<Rc<WorkerProviderState<W>>>((|_| {}).into())
.expect_throw("failed to bridge to agent.")
.0
.create_bridge(callback);
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-agent/src/worker/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
{
let ctr = use_reducer(BridgeIdState::default);

let worker_state = use_context::<WorkerProviderState<T>>()
let worker_state = use_context::<Rc<WorkerProviderState<T>>>()
.expect_throw("cannot find a provider for current agent.");

let on_output = Rc::new(on_output);
Expand Down
18 changes: 2 additions & 16 deletions packages/yew-agent/src/worker/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,6 @@ where
}
}

impl<W> Clone for WorkerProviderState<W>
where
W: Worker,
{
fn clone(&self) -> Self {
Self {
id: self.id,
spawn_bridge_fn: self.spawn_bridge_fn.clone(),
reach: self.reach,
held_bridge: self.held_bridge.clone(),
}
}
}

impl<W> PartialEq for WorkerProviderState<W>
where
W: Worker,
Expand Down Expand Up @@ -152,8 +138,8 @@ where
};

html! {
<ContextProvider<WorkerProviderState<W>> context={(*state).clone()}>
<ContextProvider<Rc<WorkerProviderState<W>>> context={state.clone()}>
{children}
</ContextProvider<WorkerProviderState<W>>>
</ContextProvider<Rc<WorkerProviderState<W>>>>
}
}

0 comments on commit 96649bc

Please sign in to comment.