Skip to content

Commit

Permalink
bump mogwai, use rx_checked
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed May 11, 2020
1 parent ab342c1 commit a47704d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 9 additions & 15 deletions bin/src/framework_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,20 @@ impl Component for FrameworkCard {
tx: Transmitter<Self::ModelMsg>,
rx: Receiver<Self::ViewMsg>,
) -> Gizmo<HtmlElement> {
// Keep the row's input up to date using set_checked, as using
// html attributes is not enough.
let input:Gizmo<HtmlInputElement> = input();
input.set_checked(self.is_enabled);
let input_self:HtmlInputElement = (&input as &HtmlInputElement).clone();
rx.branch().respond(move |msg| match msg {
Out::IsEnabled(is_enabled) => {
input_self.set_checked(*is_enabled);
}
_ => {}
});

tr()
.with(
td().with({
td().with(
// Add the input inline in the DOM
input
input()
.attribute("type", "checkbox")
.tx_on("click", tx.contra_map(|_| In::ToggleEnabled))
}),
.rx_checked(self.is_enabled, rx.branch_filter_map(|msg| match msg {
Out::IsEnabled(is_enabled) => {
Some(*is_enabled)
}
_ => { None }
}))
),
)
.with(td().with(
a().attribute("href", &self.url).text(&self.name).rx_class(
Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
wee_alloc = { version = "0.4.2", optional = true }

[dependencies.mogwai]
version = "^0.2"
version = "0.2.2"
#git = "https://github.com/schell/mogwai.git"
#rev = "f4d08cf73bb8fffe6e59c1aa7fa52502b05a3e83"
#path = "../../mogwai/mogwai"
Expand Down

0 comments on commit a47704d

Please sign in to comment.