Fix missing Subscription type in iced_web
This commit is contained in:
parent
0f2e20f5e5
commit
9ca65c9f18
5 changed files with 47 additions and 3 deletions
21
web/src/hasher.rs
Normal file
21
web/src/hasher.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use std::collections::hash_map::DefaultHasher;
|
||||
|
||||
/// The hasher used to compare layouts.
|
||||
#[derive(Debug)]
|
||||
pub struct Hasher(DefaultHasher);
|
||||
|
||||
impl Default for Hasher {
|
||||
fn default() -> Self {
|
||||
Hasher(DefaultHasher::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl core::hash::Hasher for Hasher {
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
self.0.write(bytes)
|
||||
}
|
||||
|
||||
fn finish(&self) -> u64 {
|
||||
self.0.finish()
|
||||
}
|
||||
}
|
||||
|
|
@ -61,18 +61,22 @@ use std::{cell::RefCell, rc::Rc};
|
|||
|
||||
mod bus;
|
||||
mod element;
|
||||
mod hasher;
|
||||
|
||||
pub mod style;
|
||||
pub mod subscription;
|
||||
pub mod widget;
|
||||
|
||||
pub use bus::Bus;
|
||||
pub use dodrio;
|
||||
pub use element::Element;
|
||||
pub use hasher::Hasher;
|
||||
pub use iced_core::{
|
||||
Align, Background, Color, Command, Font, HorizontalAlignment, Length,
|
||||
VerticalAlignment,
|
||||
};
|
||||
pub use style::Style;
|
||||
pub use subscription::Subscription;
|
||||
pub use widget::*;
|
||||
|
||||
/// An interactive web application.
|
||||
|
|
|
|||
19
web/src/subscription.rs
Normal file
19
web/src/subscription.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Listen to external events in your application.
|
||||
use crate::Hasher;
|
||||
|
||||
/// A request to listen to external events.
|
||||
///
|
||||
/// Besides performing async actions on demand with [`Command`], most
|
||||
/// applications also need to listen to external events passively.
|
||||
///
|
||||
/// A [`Subscription`] is normally provided to some runtime, like a [`Command`],
|
||||
/// and it will generate events as long as the user keeps requesting it.
|
||||
///
|
||||
/// For instance, you can use a [`Subscription`] to listen to a WebSocket
|
||||
/// connection, keyboard presses, mouse events, time ticks, etc.
|
||||
///
|
||||
/// [`Command`]: ../struct.Command.html
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub type Subscription<T> = iced_core::Subscription<Hasher, (), T>;
|
||||
|
||||
pub use iced_core::subscription::Recipe;
|
||||
Loading…
Add table
Add a link
Reference in a new issue