🐶Incremental Dom + Haxe + Elm Architechture + SSR
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'.
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
- MVU
- SSR Strings
- Generic SSR functionality
- Attribute / Element array pool
- CMD line utility for new projects
- Example projects
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
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;
}
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.
Towser is MIT licensed.