Seems like these could all be handled in state.

```
type DataStatus
    = IsFetching
    | IsUpdating
    | IsCreating
    | IsDeleting

type Page
    = Login
    | SomeOtherPage

-- etc... Then you update your model with these

type alias Model = 
    { currentPage : Page
    , dataStatus : DataStatus
    , etc...
    }
```

On Monday, November 21, 2016 at 8:04:44 PM UTC-7, Charlie Koster wrote:
>
> I'm a fan of the changes to Task.perform in Elm 0.18. However, I'm still 
> finding that I'm writing a lot of boilerplate in some situations. For 
> example, there are several instances when I want to send a msg which has no 
> payload.
>
> Task.perform (\_ -> GoToLoginPage) (Task.succeed Nothing)
>
> I do this any time I am navigating to a different page, submitting a form, 
> cancelling a form, kicking off any asynchronous request (logging in, 
> CRUDing any data), and maybe one or two other special cases.
>
> I don't see any reason why not have a function in Task that takes a msg 
> and returns a Cmd msg.
>
> sendMsg : msg -> Cmd msg
>
> Which could be used like this
>
> Task.sendMsg GoToLoginPage
> Task.sendMsg GoToOneOfTenOtherPages
> Task.sendMsg IsFetchingData
> Task.sendMsg IsUpdatingData
> Task.sendMsg IsCreatingData
> Task.sendMsg IsDeletingData
> Task.sendMsg CancelCreate
> Task.sendMsg CancelDelete
> Task.sendMsg LogoutSucceed
> ...
>
> Any thoughts on this proposed addition? Does anyone else find themselves 
> writing a lot of boilerplate with Task.perform?
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to