towser

Incremental Dom + Haxe + Elm Architechture
https://github.com/PongoEngine/Towser

To install, run:

haxelib install towser 0.1.1 

See using Haxelib in Haxelib documentation for more information.

README.md

Towser

Towser Build Status Join the chat at https://gitter.im/pongo-towser/community

🐶Incremental Dom + Haxe + Elm Architechture + SSR

Table of Contents

About

Towser is the Mutable Elm Architechture built using Haxe and Google's Incremental-Dom. Towser can easily be adopted into any node framework for serverside rendering using the compiler define '-D backend'.

Current Tasks

Towser is fully functional for making MVU applications but is far from being complete. Below is what you can expect now and in the future. - [ ] Documentation - [x] MVU - [x] SSR Strings - [ ] Generic SSR functionality - [ ] Attribute / Element array pool - [ ] CMD line utility for new projects - [ ] Example projects

Features

A few of the features you get with Towser - One-way data flow - Get / Set model - Manually trigger renders - Lazy wrappers for render functions - Mutable Elm Architcture

Hello World

import towser.RenderType;
import towser.RenderFunction;
import towser.html.Event;
import towser.html.Attributes.*;
import towser.html.Html.*;
import towser.html.Events.*;
import towser.Towser;

class TestApp {
	public static function view(model:Model) : RenderFunction<Model, Msg>
	{
		return switch model.section {
			case Hello: div([class_("full-screen"), onclick(ChangeName.bind("Robot"))], [
				h1([], [text("Hello")]),
				p([], [text(model.name)])
			]);
			case VoidElements: div([], [
				area([]),
				br([]),
				col([]),
				embed([]),
				hr([]),
				img([]),
				input([]),
				param([]),
				source([]),
				track([]),
				wbr([])
			]);
		}
	}

	public static function update(towser :Towser<Model, Msg>, msg:Msg, model:Model) : RenderType<Model, Msg> 
	{
		return switch msg {
			case ChangeName(name, e):
				model.name = name;
				FULL;
			case ChangeSection(section_):
				model.section = section_;
				FULL;
		}
	}
}

enum Msg {
	ChangeName(name :String, e :MouseEvent);
	ChangeSection(section :Section);
}

typedef Model =
{
	var name :String;
	var section :Section;
}

enum Section
{
	Hello;
	VoidElements;
}

Why Haxe and why Mutability?

Haxe is a strongly typed programming language that transpiles to other target languages. It has many functional qualities like exhaustive pattern matching, first class functions, and currying to name a few. These functional features adapt to the Elm Architecture quite well given that Elm is a functional language. Additionaly Haxe has Abstracts which wrap concrete types. These abstract wrappers come with zero runtime cost and make for wonderful APIs. Lastly haxe has mutable data types. I love making games and although it is possible to make a purely functional game I would rather not.

License

Towser is MIT licensed.

Contributors
Jeremy
Version
0.1.1
Published
5 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub