AaronErhardt / AaronErhardt.github.io

My personal blog
https://aaronerhardt.github.io
3 stars 4 forks source link

Further improvements #49

Closed tronta closed 3 years ago

tronta commented 3 years ago

in the widget macro I thought it would make sense to change the order. What do you think?

AaronErhardt commented 3 years ago

That's funny, I was just working on the same thing. The problem with the reusable components chapter is, that we only implement the component not the app. So there needs to be some text explaining that.

Maybe something like this (I've fixed something in the last sentence as well )

# Reusable components

In this chapter, we will implement a simple alert dialog as a reusable component.

The alert example in the Relm4 repository implements a simple app for the reusable alert component we will write in this chapter. It's an other variant of a counter app, yet this time a dialog will be displayed if the counter does not match 42 when being closed. The main difference in the implementation is, that the dialog is implemented as component that can be reused in other applications.

![App screenshot dark](img/screenshots/reusable-alert-dark-1.png)

This is how the dialog looks like in the alert example:

![App screenshot dark](img/screenshots/reusable-alert-dark-2.png)

> If you want to see an alert component, very similar to the one we will write in this chapter, used inside a Relm4 application have a look at the [“alert” example](https://github.com/AaronErhardt/relm4/blob/main/relm4-examples/examples/alert.rs). Run `cargo run --example alert` from the [example directory](https://github.com/AaronErhardt/relm4/tree/main/relm4-examples) if you want to see the code in action.

Reusable components don’t know their parent component at the time they are implemented. So if they want to interact with their parent component, they must assume that their parent model implements a trait as an interface for the component.
tronta commented 3 years ago

Sounds good. I guess we can close mine.