On Thursday, November 2, 2017 at 12:56:52 PM UTC+1, Martin Janiczek wrote:
 

> I have added a Navigation middleware example, see the updated demo: 
> https://janiczek.github.io/middleware/index.html
> (Because *elm-lang/navigation* doesn't expose the *Location -> msg -> Sub 
> msg*, I've had to copy it to the user-space code to be able to connect 
> the subscription to the middleware.)
>

(Of course I meant *(Location -> msg) -> Sub msg*.)

It seems to me that the Navigation example doesn't gain much from being 
written in middleware pattern. It's *better than the *.program approach* in 
that it can compose, but it's *worse than Sub approach* in that user 
doesn't see where the Location msg came from. (In my opinion, it's better 
to be explicit.)
The time-travel middleware does, I think, still have its value in being in 
the middleware pattern: it's more "invasive" change, *view* and all, and 
wouldn't be suited by simple Cmd/Sub.

I assume the reason Navigation has opted for the *.program approach, is the 
custom *init* function. This (init) is one thing I haven't yet thought 
about much for the middleware, and is probably subject to change. There 
probably exists some nice middleware example that would make the API more 
clear. Food for thought :)

-- 
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