thoth-org / Thoth.Elmish.Toast

https://thoth-org.gitbook.io/thoth-elmish-toast/
MIT License
6 stars 4 forks source link

Add modal dialogs #3

Open alfonsogarciacaro opened 5 years ago

alfonsogarciacaro commented 5 years ago

It'd be great to have also the possibility of creating modal dialogs as Elmish commands, maybe here or in a different package.

MangelMaxime commented 5 years ago

If the modal is created using Elmish commands it will be static. Because the state can't be stored in the global model and no I don't want to speak about hook or stateful components for designing such a components ^^.

It could call a callback but probably nothing more but even then it's dangerous in development mode and could lead to broken applications.

If an HMR call is triggered while the modal is open, then the callbacks in the modal will not have the right dispatch instance and will probably just throw an error or do nothing on click.

Why do you want to create a model using a command instead of storing the state of the modal in your application and calling the modal in the view?

alfonsogarciacaro commented 5 years ago

Well, if you have a complicated app with a view that you don't remember very well and don't want to touch very much (as it just happened to me) and you're asked to add a confirmation step for an action, it could be a nice way to quickly add the confirmation in your update function.

A static modal is ok as long as you have access to the dispatch function and another function to dismiss the modal. The HMR thing is indeed tricky but I personally could leave with that (I just refresh when I see the app behaving funny).

alfonsogarciacaro commented 5 years ago

Zaid made me realize he has already something like that. It'd be nice to have something similar for Fulma apps :) https://zaid-ajaj.github.io/Elmish.SweetAlert/

MangelMaxime commented 5 years ago

Hum...

The thing is all the modal provided by SweetAlert can only support a small kind of things. But indeed, perhaps we can try to cover the most common cases.