Coder Social home page Coder Social logo

elm-lifecycle's Introduction

A symmetrical simplified Elm lifecycle diagram.

Elm Lifecycle

Below is a simplified description of events just to help follow along the above diagram. For more detailed descriptions of Elm workflow please see one of the following resources:

init

An HTML.App.program is created within the main function of an Elm program. The Html.App.program initiates the Elm application by calling your init function. This creates a (Model, Cmd Msg) tuple which is handed off to the Elm runtime.

  1. main is called
  2. Html.App.program is called within main
  3. Html.App.program calls your init function
  4. The init function returns a (Model, Cmd Msg) tuple which is handed off to the Elm runtime
  5. The Elm runtime runs the Cmd and then calls your update function with the resultant Msg and Model (thus closing the "update loop")
  6. update then returns a new (Model, Cmd Msg) tuple
  7. the update loop may continue until no more Cmds are run

Once the Elm program has been initialized and a view is rendered to the screen then further updates come from either subscription to external events such as time, or a web socket; or from user interaction with the view.

subscriptions

  1. an external event occurs to which your application is subscribed
  2. the subscriptions function passes a Sub Msg to the Elm runtime The Msg will most likely contain a payload from the event.
  3. the Elm runtime passes the Msg (with its payload) and the current Model to your update function (thus beginning the update loop)

view

  1. the user interacts with the view (clicks a button, mouseover a div etc)
  2. if an Html.Events event has been configured for the user behavior, then an Html Msg is passed to the Elm runtime.
  3. the Elm runtime passes the Msg (with its payload) and the current Model to your update function (thus beginning the update loop)

elm-lifecycle's People

Contributors

plaxdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elm-lifecycle's Issues

Accompanying text

Love the graphic! Very clean!

Would love to see accompanying text underneath to follow a typical flow...

i.e.

1. User interacts with view
2. Msg handled by update
...

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.