Closed dakom closed 3 years ago
@Pauan - thoughts?
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);
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.
(paste
looks amazing though, I've wanted that functionality before, so thanks for pointing that out)
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 :)
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