Skip to content

Latest commit

 

History

History
 
 

mithril

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Unearth Mithril.js guide

A mostly reasonable approach to Mithril and JSX

Table of Contents

  1. Basic Rules
  2. Models

Basic Rules

  • Split code by view and model.
  • Only one model per file.
  • Multiple components are allowed in a single file. (Don't abuse this)

Models

2.1 General

The model is tied to a view or views. The Model is used to execute logic and hold state for the view it is tied to.

⬆ back to top 2.2 Use classes.

Why? It is easier to refactor the model to support multiple instances if the model is already a class.

    // bad
    const model = {
        init() {
            // do init
        }
    }

    export default model;

    // good
    class Model {
        init() {

        }
    }

    export default new Model();

    // good
    class Model {
        init() {

        }
    }

    export default Model;

⬆ back to top