Migration from v0.2 to v0.4
Fortunately, there aren't many big breaking changes in version 0.4 despite a lot of improvements under the hood.
In case you're wondering what happened to version 0.3, Relm4 now tries to follow the version number of gtk4-rs and therefore skipped v0.3.
FactoryPrototype
The methods of FactoryPrototype
were renamed to better match the rest of Relm4's traits.
generate
=>init_view
update
=>view
get_root
=>root_widget
widget
macro
manual_view
was renamed topost_view
andpre_view
was added to run code before the macro generated code in the view function.component!
was removed, components are now accessible without extra code.parent!
was added to access the parent widgets which previously required no extra code.
Components
The Components
trait now has a new method called connect_parent
.
This method doesn't do much more than passing the parent widgets down to individual components and originated unintentionally in the rework of the initialization process.
Because this method is usually just repetitive code, you can now use the derive macro instead:
#[derive(relm4::Components)]
struct AppComponents {
header: RelmComponent<HeaderModel, AppModel>,
dialog: RelmComponent<DialogModel, AppModel>,
}
The derive macro will always use RelmWorker::with_new_thread()
for workers.
Also, RelmComponent::with_new_thread()
was removed due to the restructuring.
It's recommended to use workers or message handlers for blocking operations instead.
If there's anything missing, let me know. You can simply open an issue on GitHub or write a message in the Matrix room.