Categories
Javascript Tutorials

Updating the Internal State of a Mithril Component

In this tutorial, we will use the ever popular “counter” example. With a twist. Instead of using setTimeout, we’ll be using the more performant requestAnimationFrame method. This will seem challenging because requestAnimationFrame is itself a closure. So how do we deal with closures inside of closures? How can we update the parent state of our [ Read More… ]

Categories
Javascript Tutorials

Managing Internal State in Mithril Components

This tutorial will highlight why you would want to use closures instead of raw objects to manage the iternal state of your mithril component. We will start by building a basic traffic light component. Right now the component is not doing much of anything, except that a lexical scope is created when the trafficLight component [ Read More… ]

Categories
Tutorials

An Introduction to Mithril Components

As with other popular frameworks, mithril allows developers to encapsulate functionality into reusable components. A mithril component is comprised of an object containing lifecycle methods and a “view” method to render HTML. vnode(s) are javascript objects that represent the virtual DOM elements. To create a vnode, an HTML element tag, id, class, or component is [ Read More… ]

Categories
Tutorials

Get Started with Mithril

This will be the first of many tutorials covering the lesser known but very powerful and performant javascript framework Mithril.js. Mithril is primarily used for SPA (Single Paged Applications) but also works well as a drop in for existing sites and in many cases a replacement for jQuery. Creating a basic HTML file Start by [ Read More… ]