A pattern I have used sometimes is to have the context passed as a list instead of a record:
type Options = OptA | OptB Float | OptC Color -- A call with default options: view [] model -- A call with custom options: view [OptA, OptC red] model Actually, now that I think of it, that is how every function in the Html module hierarchy is organized. On Thursday, May 26, 2016 at 5:07:01 AM UTC-5, Peter Damoc wrote: > > Let's say I have a module that encapsulates a series of widgets and I want > to publish this module with elm-package in order to make it available to > others. > > Let's say that there is the concept of a `primaryColor` for these widgets. > > How can I have the users change the `primaryColor`? > > I can think of only two ways: > > 1. Pass a `Context` record to each widget's view > > 2. Create a function in the module that receives such a Context and > returns a master record of all the views in order to avoid passing the > context every time. > > What other options are there? > > P.S. There is also the option to just copy the source code of the widget > module and modify the default value manually but I want to avoid this. > > > > > > -- > There is NO FATE, we are the creators. > blog: http://damoc.ro/ > -- 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.
