Pauan / rust-dominator

Zero-cost ultra-high-performance declarative DOM library using FRP signals for Rust!
MIT License
967 stars 62 forks source link

Events #25

Closed dakom closed 3 years ago

dakom commented 4 years ago
dakom commented 4 years ago

@Pauan - thoughts?

dakom commented 4 years ago

actually, using the paste crate - the following is even nicer:

macro_rules! my_make_event {
    ($type:literal, $name:ident) => {
        paste::item! {
            make_custom_event_serde!($type, [<$name Event>], $name);
        }
    }
}

Example, will create both AddTodoEvent and impl what's needed for AddTodo - but user only specifies AddTodo and the literal:

#[derive(Deserialize)]
pub struct AddTodo {
    pub label: String 
}
my_make_event!("add-todo", AddTodo);
Pauan commented 4 years ago

I think it's a bit too early to commit to make_event, especially because I want to make some changes to the event system and also fold it into gloo.

Pauan commented 4 years ago

(paste looks amazing though, I've wanted that functionality before, so thanks for pointing that out)

dakom commented 4 years ago

okay... currently I'm relying on this PR for experimental tests and such - so will build against my fork for now... but keeping 👀 on this for when you settle on an event api :)

dakom commented 3 years ago

I'm going to close this in favor of moving it to https://github.com/dakom/dominator-helpers

However, the event macros in dominator-helpers will be broken until make_event! itself is pub

(personally, I'm okay with that since I'm no longer using those event macros in production and in a pinch one could make a fork of dominator with that one change if really necessary).

Will open a new issue to track that though