summaryrefslogtreecommitdiffstats
path: root/web/src/bus.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-28 16:47:50 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-28 21:37:16 +0700
commit825c7749ff364cf1f7ae5cab0c25f27ed85c7d82 (patch)
treefdd7e499c343a7e3cf690d4b5aa40ba568674a3c /web/src/bus.rs
parent1e3feee3a36f25d7e2eda231c3e6b895858952c5 (diff)
downloadiced-825c7749ff364cf1f7ae5cab0c25f27ed85c7d82.tar.gz
iced-825c7749ff364cf1f7ae5cab0c25f27ed85c7d82.tar.bz2
iced-825c7749ff364cf1f7ae5cab0c25f27ed85c7d82.zip
Replace `iced_web` with WebGL support in `wgpu` :tada:
Diffstat (limited to '')
-rw-r--r--web/src/bus.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/web/src/bus.rs b/web/src/bus.rs
deleted file mode 100644
index 5ce8e810..00000000
--- a/web/src/bus.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use iced_futures::futures::channel::mpsc;
-use std::rc::Rc;
-
-/// A publisher of messages.
-///
-/// It can be used to route messages back to the [`Application`].
-///
-/// [`Application`]: crate::Application
-#[allow(missing_debug_implementations)]
-pub struct Bus<Message> {
- publish: Rc<Box<dyn Fn(Message) -> ()>>,
-}
-
-impl<Message> Clone for Bus<Message> {
- fn clone(&self) -> Self {
- Bus {
- publish: self.publish.clone(),
- }
- }
-}
-
-impl<Message> Bus<Message>
-where
- Message: 'static,
-{
- pub(crate) fn new(publish: mpsc::UnboundedSender<Message>) -> Self {
- Self {
- publish: Rc::new(Box::new(move |message| {
- publish.unbounded_send(message).expect("Send message");
- })),
- }
- }
-
- /// Publishes a new message for the [`Application`].
- ///
- /// [`Application`]: crate::Application
- pub fn publish(&self, message: Message) {
- (self.publish)(message)
- }
-
- /// Creates a new [`Bus`] that applies the given function to the messages
- /// before publishing.
- pub fn map<B>(&self, mapper: Rc<Box<dyn Fn(B) -> Message>>) -> Bus<B>
- where
- B: 'static,
- {
- let publish = self.publish.clone();
-
- Bus {
- publish: Rc::new(Box::new(move |message| publish(mapper(message)))),
- }
- }
-}