Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 authored May 5, 2021
1 parent 05a10b3 commit a7e23ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions packages/yew-functional/src/hooks/use_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,26 @@ where
}

/// State handle for [`use_reducer`] hook
pub struct UseReducerHandle<STATE, ACTION> {
value: Rc<STATE>,
setter: Rc<dyn Fn(ACTION)>,
pub struct UseReducerHandle<State, Action> {
value: Rc<State>,
setter: Rc<dyn Fn(Action)>,
}

impl<STATE, ACTION> UseReducerHandle<STATE, ACTION> {
pub fn dispatch(&self, value: ACTION) {
impl<State, Action> UseReducerHandle<State, Action> {
pub fn dispatch(&self, value: Action) {
(self.setter)(value)
}
}

impl<STATE, ACTION> Deref for UseReducerHandle<STATE, ACTION> {
type Target = STATE;
impl<State, Action> Deref for UseReducerHandle<State, Action> {
type Target = State;

fn deref(&self) -> &Self::Target {
&*self.value
}
}

impl<STATE, ACTION> Clone for UseReducerHandle<STATE, ACTION> {
impl<State, Action> Clone for UseReducerHandle<State, Action> {
fn clone(&self) -> Self {
Self {
value: Rc::clone(&self.value),
Expand Down
14 changes: 7 additions & 7 deletions packages/yew-functional/tests/use_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn use_effect_destroys_on_component_drop() {
}
} else {
html! {
<div>{"EMPTY"}</div>
<div>{ "EMPTY" }</div>
}
}
}
Expand Down Expand Up @@ -103,9 +103,9 @@ fn use_effect_works_many_times() {

return html! {
<div>
{"The test result is"}
<div id="result">{*counter}</div>
{"\n"}
{ "The test result is" }
<div id="result">{ *counter }</div>
{ "\n" }
</div>
};
}
Expand Down Expand Up @@ -138,9 +138,9 @@ fn use_effect_works_once() {

return html! {
<div>
{"The test result is"}
<div id="result">{*counter}</div>
{"\n"}
{ "The test result is" }
<div id="result">{ *counter }</div>
{ "\n" }
</div>
};
}
Expand Down
6 changes: 3 additions & 3 deletions packages/yew-functional/tests/use_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ fn multiple_use_state_setters() {
another_scope();
return html! {
<div>
{"Test Output: "}
{ "Test Output: " }
// expected output
<div id="result">{*counter}</div>
{"\n"}
<div id="result">{ *counter }</div>
{ "\n" }
</div>
};
}
Expand Down

0 comments on commit a7e23ab

Please sign in to comment.