Coder Social home page Coder Social logo

Handle Html in Chapter model about elm-book HOT 2 CLOSED

dtwrks avatar dtwrks commented on May 29, 2024
Handle Html in Chapter model

from elm-book.

Comments (2)

georgesboris avatar georgesboris commented on May 29, 2024

OMG the size of that PR 😅

So! By reading through some of your chapter examples I couldn't find exactly what you described. But in theory your custom model can hold anything as long as you provide the type – however, ElmBook can only handle ElmBook.Msg as the final message passed through your html. You can still map your own messages to ElmBook's though!

Like, this is fine as a data type:

-- Chapter

type alias SharedState s =
    { s | chapter : List (Html msg) }

-- Book

type alias BookState msg =
    { chapter : List (Html msg)
    }
  
main : Book (BookState msg)
main =
    ...

The problem would happen if your view had Html SomeOtherMsg – but then I don't see why wouldn't you be able to just use Html.Styles.map to change it to a valid ElmBook msg when using it on your chapter. Does this make any sense at all? Please reach me on Slack if you wanna discuss further – we can jump on a call and figure out how to make it work! :)

from elm-book.

georgesboris avatar georgesboris commented on May 29, 2024

Closing for now – but please reach me here or on Discord/Slack for further discussion! 🙇

from elm-book.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.