DEV Community

Discussion on: My first Elm app

Collapse
 
aminnairi profile image
Amin

Hi there and thanks for your article, it was really interesting!

Since your are used to use React do you think Elm could be a framework you will use instead of React and why so?

Thanks for taking the time to answer. I can't wait for the next article!

Collapse
 
selbekk profile image
selbekk

Hi!

I think they both have their merits. Having a guarantee of zero runtime errors can be a nice thing for certain apps, and I think Elm feels very robust and «safe», if you catch my drift.

I still prefer React, but that might be because I know it better. I do, however, miss the innovations like Suspense.

Collapse
 
wolfadex profile image
Wolfgang Schuster

You can get Suspense like behavior with Elm fairly easily. Create a type:

type Request e d = Loading | Completed (Result e d)

And match it up with a simple view function:

suspense : Html msg -> (Result e d -> HTML msg) -> Request e d -> Html msg
suspense loadingHtml childHtml request =
    case request of
        Loading -> loadingHtml
        Completed result -> childHtml result

There are some handy packages that also help with giving you better types for your requests, such as package.elm-lang.org/packages/ohan...

Thread Thread
 
selbekk profile image
selbekk

Cool! Yeah that does emulate some of it!