Javascript port of Flux by selvinortiz