>
> While I understand that not breaking things up too often is sound advice 
> in elm, I still think this doesn't answer my question


Here is concretely what I'd do:


type alias Model =
  { routes : List Route
  , hovered : Maybe Int
  , selected : Maybe Int
  , map : Map.InternalModel
  , table : Table.InternalModel
  , profile : Profile.InternalModel
  }

If Profile only needs a subset of the model, then its nicest implementation 
will be a standalone view function. I would not write type alias Model for 
profile; instead I would do this:

viewProfile : List Route -> Maybe Int -> InternalModel -> Html Msg

If you need to use it on multiple pages, i.e. its return type needs to be Html 
msg instead of Html msg , then give it an extra parameter so the caller can 
request its Msg of choice. For example, supposing profiles can set hovered 
(which is a Maybe Int) in response to a mouse event, I would write this:

viewProfile : (Maybe Int -> msg) -> List Route -> Maybe Int -> 
InternalModel -> Html msg

See my next answer for links on how to take this further iff you need to.

> Just break it into modules so your similar functions are grouped together 
>> in files.  Use them just like you already are.  
>>
>
> The part I don't understand is: how do you create UI components that 
> maintain their internal state without nesting them as child components?
>

You don't; since the Model is the single source of truth for application 
state, nesting is how you organize that state.

Check out elm-autocomplete 
<https://github.com/thebritican/elm-autocomplete/> and the API design 
session that went into it <https://www.youtube.com/watch?v=KSuCYUqY058> for 
the right way to do reusable widgets!

Is there some public code that shows this pattern in action?  

It would be wonderful to look at something that feels like it needs to be 
> split up and see a version that is flat. 


I don't know of one offhand, but I'm realizing I should put in the effort 
to develop one so I can show what I mean instead of trying to describe it! 
:)

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to