🐶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
importtowser.RenderType;
importtowser.RenderFunction;
importtowser.html.Event;
importtowser.html.Attributes.*;
importtowser.html.Html.*;
importtowser.html.Events.*;
importtowser.Towser;
classTestApp {
publicstaticfunctionview(model:Model) :RenderFunction<Model, Msg>
{
returnswitchmodel.section {
caseHello: div([class_("full-screen"), onclick(ChangeName.bind("Robot"))], [
h1([], [text("Hello")]),
p([], [text(model.name)])
]);
caseVoidElements: div([], [
area([]),
br([]),
col([]),
embed([]),
hr([]),
img([]),
input([]),
param([]),
source([]),
track([]),
wbr([])
]);
}
}
publicstaticfunctionupdate(towser:Towser<Model, Msg>, msg:Msg, model:Model) :RenderType<Model, Msg> {
returnswitchmsg {
caseChangeName(name, e):
model.name=name;
FULL;
caseChangeSection(section_):
model.section=section_;
FULL;
}
}
}
enumMsg {
ChangeName(name:String, e:MouseEvent);
ChangeSection(section:Section);
}
typedefModel=
{
varname:String;
varsection:Section;
}
enumSection
{
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.