jazzfool / reclutch

Rust UI Core
Other
157 stars 4 forks source link

Refactoring #1

Closed fogti closed 4 years ago

fogti commented 4 years ago

I tried to make the Event API/interface more ergonomic.

Similiar to another refactoring which I did in the past (https://gitlab.com/tglman/persy/merge_requests/8), I changed the EventListener such that it contains a reference to the associated Event, and wrapped this reference inside an Arc<Mutex<>> to make it thread-safe. Listeners now de-register themselves in the destructor (Drop trait).

Additionally, I tried to get rid of some clippy warnings.

And then I noticed that the global argument in Widget::update calls isn't used anymore and could be dropped.

P.S.: I think that the event part of widget.rs should be split into a separate file, because it is independent of the Widget trait.

fogti commented 4 years ago

I am not sure if thread-safety is required in the event system, but it would be a nice-to-have.

jazzfool commented 4 years ago

This is great! Thanks a lot.