Breaking change: replacing hidden and hidden_signal with visible and visible_signal
This commit is contained in:
parent
5c86d8d69a
commit
ba3f26eb2b
|
@ -10,12 +10,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dominator"
|
name = "dominator"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-channel-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-channel-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-signals 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-signals 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pin-utils 0.1.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pin-utils 0.1.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -68,7 +68,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-signals"
|
name = "futures-signals"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -298,7 +298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e5fea6d4920bf1745d87f8624abdd38ed03fb5b644767b84a0de882fe46c4153"
|
"checksum futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e5fea6d4920bf1745d87f8624abdd38ed03fb5b644767b84a0de882fe46c4153"
|
||||||
"checksum futures-executor-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "43d4bb2cc4c0cefc554b0cf12f7151e0a578cf1820a36453eff1d955dde762ff"
|
"checksum futures-executor-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "43d4bb2cc4c0cefc554b0cf12f7151e0a578cf1820a36453eff1d955dde762ff"
|
||||||
"checksum futures-io-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "91bd6aba63f52d532c0f4ca6e9960f80a1b4295c292362baf2cad6d739fa9123"
|
"checksum futures-io-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "91bd6aba63f52d532c0f4ca6e9960f80a1b4295c292362baf2cad6d739fa9123"
|
||||||
"checksum futures-signals 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3973c4e41654b7d70a75dfebd10ef4291beefa06ac410e5ab42eb577f67b640"
|
"checksum futures-signals 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7cb40fb22df6b8f8e0ddf9daf3aa31370f460d52306c6b405cec303892bde9e"
|
||||||
"checksum futures-sink-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd7799480a224d80e9e915a6bf8bff27498e8210b831f5a513af09d5c1db2e36"
|
"checksum futures-sink-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd7799480a224d80e9e915a6bf8bff27498e8210b831f5a513af09d5c1db2e36"
|
||||||
"checksum futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b73a6f85964a8291914db0114ccb0045c994c58b2110c4cf4ac47f5d2176ec90"
|
"checksum futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b73a6f85964a8291914db0114ccb0045c994c58b2110c4cf4ac47f5d2176ec90"
|
||||||
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
||||||
|
|
|
@ -18,7 +18,7 @@ pin-utils = "0.1.0-alpha.3"
|
||||||
futures-core-preview = "0.3.0-alpha.7"
|
futures-core-preview = "0.3.0-alpha.7"
|
||||||
futures-channel-preview = "0.3.0-alpha.7"
|
futures-channel-preview = "0.3.0-alpha.7"
|
||||||
futures-util-preview = "0.3.0-alpha.7"
|
futures-util-preview = "0.3.0-alpha.7"
|
||||||
futures-signals = "0.2.0"
|
futures-signals = "0.2.1"
|
||||||
|
|
||||||
[dependencies.stdweb]
|
[dependencies.stdweb]
|
||||||
version = "0.4.10"
|
version = "0.4.10"
|
||||||
|
|
|
@ -10,12 +10,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dominator"
|
name = "dominator"
|
||||||
version = "0.2.0"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-channel-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-channel-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-signals 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-signals 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pin-utils 0.1.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pin-utils 0.1.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -68,7 +68,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-signals"
|
name = "futures-signals"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -279,8 +279,8 @@ dependencies = [
|
||||||
name = "todomvc"
|
name = "todomvc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dominator 0.2.0",
|
"dominator 0.2.3",
|
||||||
"futures-signals 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-signals 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -310,7 +310,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e5fea6d4920bf1745d87f8624abdd38ed03fb5b644767b84a0de882fe46c4153"
|
"checksum futures-core-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e5fea6d4920bf1745d87f8624abdd38ed03fb5b644767b84a0de882fe46c4153"
|
||||||
"checksum futures-executor-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "43d4bb2cc4c0cefc554b0cf12f7151e0a578cf1820a36453eff1d955dde762ff"
|
"checksum futures-executor-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "43d4bb2cc4c0cefc554b0cf12f7151e0a578cf1820a36453eff1d955dde762ff"
|
||||||
"checksum futures-io-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "91bd6aba63f52d532c0f4ca6e9960f80a1b4295c292362baf2cad6d739fa9123"
|
"checksum futures-io-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "91bd6aba63f52d532c0f4ca6e9960f80a1b4295c292362baf2cad6d739fa9123"
|
||||||
"checksum futures-signals 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3973c4e41654b7d70a75dfebd10ef4291beefa06ac410e5ab42eb577f67b640"
|
"checksum futures-signals 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7cb40fb22df6b8f8e0ddf9daf3aa31370f460d52306c6b405cec303892bde9e"
|
||||||
"checksum futures-sink-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd7799480a224d80e9e915a6bf8bff27498e8210b831f5a513af09d5c1db2e36"
|
"checksum futures-sink-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd7799480a224d80e9e915a6bf8bff27498e8210b831f5a513af09d5c1db2e36"
|
||||||
"checksum futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b73a6f85964a8291914db0114ccb0045c994c58b2110c4cf4ac47f5d2176ec90"
|
"checksum futures-util-preview 0.3.0-alpha.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b73a6f85964a8291914db0114ccb0045c994c58b2110c4cf4ac47f5d2176ec90"
|
||||||
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
||||||
|
|
|
@ -226,9 +226,9 @@ fn main() {
|
||||||
.class("main")
|
.class("main")
|
||||||
|
|
||||||
// Hide if it doesn't have any todos.
|
// Hide if it doesn't have any todos.
|
||||||
.property_signal("hidden", state.todo_list.signal_vec_cloned()
|
.visible_signal(state.todo_list.signal_vec_cloned()
|
||||||
.len()
|
.len()
|
||||||
.map(|len| len == 0))
|
.map(|len| len > 0))
|
||||||
|
|
||||||
.children(&mut [
|
.children(&mut [
|
||||||
html!("input", {
|
html!("input", {
|
||||||
|
@ -273,8 +273,7 @@ fn main() {
|
||||||
|
|
||||||
.class_signal("completed", todo.completed.signal())
|
.class_signal("completed", todo.completed.signal())
|
||||||
|
|
||||||
.property_signal("hidden",
|
.visible_signal(map_ref!(
|
||||||
map_ref!(
|
|
||||||
let filter = state.filter.signal(),
|
let filter = state.filter.signal(),
|
||||||
let completed = todo.completed.signal() =>
|
let completed = todo.completed.signal() =>
|
||||||
match *filter {
|
match *filter {
|
||||||
|
@ -283,7 +282,7 @@ fn main() {
|
||||||
Filter::All => true,
|
Filter::All => true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.dedupe_map(|show| !*show))
|
.dedupe())
|
||||||
|
|
||||||
.children(&mut [
|
.children(&mut [
|
||||||
html!("div", {
|
html!("div", {
|
||||||
|
@ -325,8 +324,8 @@ fn main() {
|
||||||
.property_signal("value", todo.editing.signal_cloned()
|
.property_signal("value", todo.editing.signal_cloned()
|
||||||
.map(|x| x.unwrap_or_else(|| "".to_owned())))
|
.map(|x| x.unwrap_or_else(|| "".to_owned())))
|
||||||
|
|
||||||
.property_signal("hidden", todo.editing.signal_cloned()
|
.visible_signal(todo.editing.signal_cloned()
|
||||||
.map(|x| x.is_none()))
|
.map(|x| x.is_some()))
|
||||||
|
|
||||||
// TODO dedupe this somehow ?
|
// TODO dedupe this somehow ?
|
||||||
.focused_signal(todo.editing.signal_cloned()
|
.focused_signal(todo.editing.signal_cloned()
|
||||||
|
@ -373,9 +372,9 @@ fn main() {
|
||||||
.class("footer")
|
.class("footer")
|
||||||
|
|
||||||
// Hide if it doesn't have any todos.
|
// Hide if it doesn't have any todos.
|
||||||
.property_signal("hidden", state.todo_list.signal_vec_cloned()
|
.visible_signal(state.todo_list.signal_vec_cloned()
|
||||||
.len()
|
.len()
|
||||||
.map(|len| len == 0))
|
.map(|len| len > 0))
|
||||||
|
|
||||||
.children(&mut [
|
.children(&mut [
|
||||||
html!("span", {
|
html!("span", {
|
||||||
|
@ -418,11 +417,11 @@ fn main() {
|
||||||
.class("clear-completed")
|
.class("clear-completed")
|
||||||
|
|
||||||
// Hide if it doesn't have any completed items.
|
// Hide if it doesn't have any completed items.
|
||||||
.property_signal("hidden", state.todo_list.signal_vec_cloned()
|
.visible_signal(state.todo_list.signal_vec_cloned()
|
||||||
.map_signal(|todo| todo.completed.signal())
|
.map_signal(|todo| todo.completed.signal())
|
||||||
.filter(|completed| *completed)
|
.filter(|completed| *completed)
|
||||||
.len()
|
.len()
|
||||||
.map(|len| len == 0))
|
.map(|len| len > 0))
|
||||||
|
|
||||||
.event(clone!(state => move |_: ClickEvent| {
|
.event(clone!(state => move |_: ClickEvent| {
|
||||||
state.todo_list.lock_mut().retain(|todo| todo.completed.get() == false);
|
state.todo_list.lock_mut().retain(|todo| todo.completed.get() == false);
|
||||||
|
|
10
src/dom.rs
10
src/dom.rs
|
@ -11,7 +11,7 @@ use operations;
|
||||||
use operations::for_each;
|
use operations::for_each;
|
||||||
use dom_operations;
|
use dom_operations;
|
||||||
use operations::{ValueDiscard, FnDiscard, spawn_future};
|
use operations::{ValueDiscard, FnDiscard, spawn_future};
|
||||||
use futures_signals::signal::Signal;
|
use futures_signals::signal::{Signal, not};
|
||||||
use futures_signals::signal_vec::SignalVec;
|
use futures_signals::signal_vec::SignalVec;
|
||||||
use futures_core::Poll;
|
use futures_core::Poll;
|
||||||
use futures_core::task::LocalWaker;
|
use futures_core::task::LocalWaker;
|
||||||
|
@ -776,8 +776,8 @@ impl<A: IHtmlElement> DomBuilder<A> {
|
||||||
|
|
||||||
// TODO make this more efficient
|
// TODO make this more efficient
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden(self) -> Self {
|
pub fn visible(self, value: bool) -> Self {
|
||||||
self.property("hidden", true)
|
self.property("hidden", !value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,8 +846,8 @@ impl<A: IHtmlElement + Clone + 'static> DomBuilder<A> {
|
||||||
|
|
||||||
// TODO make this more efficient
|
// TODO make this more efficient
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden_signal<B>(self, value: B) -> Self where B: Signal<Item = bool> + 'static {
|
pub fn visible_signal<B>(self, value: B) -> Self where B: Signal<Item = bool> + 'static {
|
||||||
self.property_signal("hidden", value)
|
self.property_signal("hidden", not(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue