wasm_gloo_dom_events/
lib.rs1use ::futures::{channel::mpsc, stream::Stream};
2use ::gloo::{events::EventListener, history::{HistoryListener, Location}, render::AnimationFrame, timers::callback::{Interval, Timeout}};
3use ::std::{cell::RefCell, pin::Pin, rc::Rc, task::{Context, Poll}};
4use ::web_sys::{Event as BrowserEvent, CustomEvent};
5
6enum Listener {
7 Event(EventListener),
8 History(HistoryListener),
9 Render(AnimationFrame),
10 Interval(Interval),
11 Timeout(Timeout)
12}
13pub enum Event {
14 Event(BrowserEvent),
15 Location(Location),
16 String(String),
17 F64(f64),
18 None
19}
20pub enum Vm {
21 Browser(CustomEvent),
22 Nodejs(String)
23}
24pub struct EventStream {
25 sender: Rc<RefCell<mpsc::UnboundedSender<Event>>>,
26 receiver: mpsc::UnboundedReceiver<Event>,
27 _listener: Listener,
28}
29impl Stream for EventStream {
30 type Item = Event;
31 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
32 Pin::new(&mut self.receiver).poll_next(cx)
33 }
34}
35#[path ="./browser-dom-element.rs"]
36mod browser_dom_element;
37pub use browser_dom_element::Options;
38#[path ="./browser-history.rs"]
39mod browser_history;
40#[path ="./browser-animation-frame.rs"]
41mod browser_animation_frame;
42mod interval;
43mod timeout;