diff --git a/Cargo.lock b/Cargo.lock index 5d808a5..23fd02b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,11 +177,14 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "concoct" -version = "0.8.0-alpha.3" -source = "git+https://github.com/concoct-rs/concoct#585dfa6d5b54e9134b9f4ebf06d8e4d26f6d2fcf" +version = "0.10.1" +source = "git+https://github.com/concoct-rs/concoct#d460fd10ee93511d810914e2591bddef103fd406" dependencies = [ "futures", + "hashbrown", + "rustc-hash", "slotmap", + "tokio", ] [[package]] @@ -834,6 +837,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "scoped-tls" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 62ad9d0..9a3e462 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ kurbo = "0.9.5" tokio = { version = "1.32.0", features = ["full"] } slotmap = "1.0.7" winit = { version = "0.28.1" } -concoct = { git = "https://github.com/concoct-rs/concoct" } +concoct = { git = "https://github.com/concoct-rs/concoct", features = ["full"] } viewbuilder-macros = { path = "macros" } web-sys = { version = "0.3.66", optional = true, features = ["Document", "HtmlElement", "Text", "Window"] } diff --git a/README.md b/README.md index 8482236..ee93f17 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ struct App { impl Object for App {} impl Slot for App { - fn handle(&mut self, _cx: Context, msg: window::Resized) { + fn handle(&mut self, _cx: Handle, msg: window::Resized) { if msg.width != self.size.width { self.width_text.send(format!("Width: {}", msg.width).into()); self.size.width = msg.width diff --git a/examples/app.rs b/examples/app.rs index 9c0ba01..ba8d6d6 100644 --- a/examples/app.rs +++ b/examples/app.rs @@ -1,4 +1,4 @@ -use concoct::{Context, Handle, Object, Slot}; +use concoct::{ Handle, Object, Slot}; use viewbuilder::native::{ view::{LinearLayout, Text}, window, Window, @@ -14,7 +14,7 @@ struct App { impl Object for App {} impl Slot for App { - fn handle(&mut self, _cx: Context, msg: window::Resized) { + fn handle(&mut self, _cx: Handle, msg: window::Resized) { if msg.width != self.size.width { self.width_text.send(format!("Width: {}", msg.width).into()); self.size.width = msg.width @@ -30,16 +30,16 @@ impl Slot for App { #[viewbuilder::main] fn main() { - let width_text = Text::default().spawn(); - let height_text = Text::default().spawn(); + let width_text = Text::default().start(); + let height_text = Text::default().start(); let app = App { width_text: width_text.clone(), height_text: height_text.clone(), size: PhysicalSize::default(), } - .spawn(); + .start(); - let window = Window::new(LinearLayout::new((width_text, height_text))).spawn(); + let window = Window::new(LinearLayout::new((width_text, height_text))).start(); window.bind(&app); } diff --git a/src/native/element.rs b/src/native/element.rs index 09f3669..5430d19 100644 --- a/src/native/element.rs +++ b/src/native/element.rs @@ -9,7 +9,7 @@ impl Object for Element {} pub struct LayoutMessage; impl Slot for Element { - fn handle(&mut self, _handle: concoct::Context, _msg: LayoutMessage) { + fn handle(&mut self, _handle: concoct::Handle, _msg: LayoutMessage) { todo!() } } diff --git a/src/native/mod.rs b/src/native/mod.rs index 208475d..a23b4fd 100644 --- a/src/native/mod.rs +++ b/src/native/mod.rs @@ -1,4 +1,4 @@ -use concoct::{Runtime, RuntimeGuard, SlotHandle}; +use concoct::{Runtime, SlotHandle, rt::RuntimeGuard}; use std::{cell::RefCell, collections::HashMap, rc::Rc}; use window::WindowMessage; use winit::{ diff --git a/src/native/view/mod.rs b/src/native/view/mod.rs index 73d5c49..afa200a 100644 --- a/src/native/view/mod.rs +++ b/src/native/view/mod.rs @@ -24,7 +24,7 @@ where type View = V; fn into_view(self) -> Handle { - self.spawn() + self.start() } } diff --git a/src/native/view/text.rs b/src/native/view/text.rs index 7504160..895674e 100644 --- a/src/native/view/text.rs +++ b/src/native/view/text.rs @@ -19,7 +19,7 @@ impl Object for Text {} impl View for Text {} impl Slot> for Text { - fn handle(&mut self, _handle: concoct::Context, msg: Rc) { + fn handle(&mut self, _handle: concoct::Handle, msg: Rc) { dbg!(msg); } } diff --git a/src/native/window.rs b/src/native/window.rs index f8bd51d..60e7e82 100644 --- a/src/native/window.rs +++ b/src/native/window.rs @@ -1,11 +1,11 @@ use super::{view::IntoView, UserInterface}; -use concoct::{Context, Handle, Object, Signal, Slot}; +use concoct::{ Handle, Object, Signal, Slot}; use std::ops::Deref; use winit::dpi::PhysicalSize; pub struct Window { view: Handle, - cx: Option>, + cx: Option>, } impl Window { @@ -18,7 +18,7 @@ impl Window { } impl Object for Window { - fn start(&mut self, cx: Context) { + fn started(&mut self, cx: Handle) { UserInterface::current() .inner .borrow_mut() @@ -45,7 +45,7 @@ impl Signal for Window {} pub struct SetSize {} impl Slot for Window { - fn handle(&mut self, _handle: Context, _msg: SetSize) {} + fn handle(&mut self, _handle: Handle, _msg: SetSize) {} } pub enum WindowMessage { @@ -53,7 +53,7 @@ pub enum WindowMessage { } impl Slot for Window { - fn handle(&mut self, handle: Context, msg: WindowMessage) { + fn handle(&mut self, handle: Handle, msg: WindowMessage) { match msg { WindowMessage::Resized(size) => handle.emit(Resized(size)), } diff --git a/src/web/mod.rs b/src/web/mod.rs index 064ddf4..03efe41 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -20,7 +20,7 @@ where type View = V; fn into_view(self) -> Handle { - self.spawn() + self.start() } } @@ -111,7 +111,7 @@ impl View for Element { pub struct AppendChild(pub Handle); impl Slot> for Element { - fn handle(&mut self, _handle: concoct::Context, msg: AppendChild) { + fn handle(&mut self, _handle: concoct::Handle, msg: AppendChild) { self.element.append_child(msg.0.borrow().node()).unwrap(); } } @@ -148,5 +148,5 @@ impl View for Text { impl Object for Text {} impl Slot for Text { - fn handle(&mut self, _handle: concoct::Context, _msg: String) {} + fn handle(&mut self, _handle: concoct::Handle, _msg: String) {} } diff --git a/web-examples/Cargo.toml b/web-examples/Cargo.toml index d834740..e96268b 100644 --- a/web-examples/Cargo.toml +++ b/web-examples/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" [dependencies] viewbuilder = { path = "../", features = ["full"] } -concoct = { git = "https://github.com/concoct-rs/concoct" } +concoct = { git = "https://github.com/concoct-rs/concoct", features = ["full"] } diff --git a/web-examples/src/main.rs b/web-examples/src/main.rs index 29be5c2..443c374 100644 --- a/web-examples/src/main.rs +++ b/web-examples/src/main.rs @@ -15,7 +15,7 @@ struct Counter { impl Object for Counter {} impl Slot for Counter { - fn handle(&mut self, _cx: concoct::Context, msg: Message) { + fn handle(&mut self, _cx: concoct::Handle, msg: Message) { match msg { Message::Increment => self.value += 1, Message::Decrement => self.value -= 1, @@ -32,31 +32,31 @@ struct CounterButton { impl Object for CounterButton {} impl Slot for CounterButton { - fn handle(&mut self, _cx: concoct::Context, _msg: web::MouseEvent) { + fn handle(&mut self, _cx: concoct::Handle, _msg: web::MouseEvent) { self.counter.send(self.msg); } } #[viewbuilder::main] fn main() { - let text = Text::new("0").spawn(); + let text = Text::new("0").start(); let counter = Counter { value: 0, text: text.clone(), } - .spawn(); + .start(); let increment_button = CounterButton { msg: Message::Increment, counter: counter.clone(), } - .spawn(); + .start(); let decrement_button = CounterButton { msg: Message::Decrement, counter, } - .spawn(); + .start(); Element::builder() .child(( @@ -71,5 +71,5 @@ fn main() { .build(), )) .build() - .spawn(); + .start(); }