Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with Feliz.useElmish #44

Open
PawelStadnicki opened this issue May 18, 2022 · 1 comment
Open

Use with Feliz.useElmish #44

PawelStadnicki opened this issue May 18, 2022 · 1 comment

Comments

@PawelStadnicki
Copy link

PawelStadnicki commented May 18, 2022

In standard Elmish, Toast requires "registration" in the program entity:

Program.mkProgram init update view
|> Toast.Program.withToast Toast.render
|> Program.run

I wonder if it is possible to use this library along with Feliz hooks .
It still will be command on Update:

state, 
      Toast.message "I am toast of type Info"
      |> Toast.title "Info"
      |> Toast.info

but I have no idea where the registration part should happen.
I'm not asking how to do it, expecting implementation changes required,
just checking if this is feasible and with what effort.

@MangelMaxime
Copy link
Contributor

MangelMaxime commented May 20, 2022

Hello,

I don't think it can work because Feliz don't expect an Elmish program with a view because it doesn't offer a clean way to attach the view.

I guess you could pass a program with a Program.withReact instruction but it would feel dirty to mount a react application inside of a react app.

I think React portal are a way to fix it but I don't know if this will require fixes from Feliz too or just Thoth.Elmish.Toast.

In React world there is https://www.npmjs.com/package/react-toastify which seems to offer something equivalent but using Hooks API instead.

There is also https://react-hot-toast.com/ which is smaller if bundle size is important to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants