Any haxe js working example?

138 views
Skip to first unread message

JSH

unread,
Jul 16, 2014, 2:10:12 PM7/16/14
to haxe...@googlegroups.com
Hi guys, 

I tried to find previous posts for decent example of haxe javascript project, but there was no luck.
Does anyone know where to download or see a working example with source codes ? (such as whole source for a interactive website using jquery, or  js based mobile web, anything...)
Just want to see how things are implemented in haxe and want to learn common practices and tips through the codes.
Many thanks in advance.

Steve.

Marc Weber

unread,
Jul 16, 2014, 2:26:27 PM7/16/14
to haxelang

std implementation (shipping with haxe):
http://api.haxe.org/js/JQuery.html

alternative:
http://blog.onthewings.net/2010/08/03/using-jquery-in-haxe/


lib.haxe.org lists many js like libraries (server /client).

The most important question is: When to use js libraries and when to
rewrite code in haxe. And this is not always easy to answer.

Also there are multiple ways: use jquery's post or haxe's std
implementation. In the end there are multiple ways, and using juqueries
post could possible be even simpler eventually .. :/ (Just to name an
example).

Marc Weber

Cambiata

unread,
Jul 16, 2014, 7:07:28 PM7/16/14
to haxe...@googlegroups.com
Hi JSH!

I've spent some recent time to get going with Franco Ponticelli's Haxe externs of ReactJS (reactjs.org).
Have a look at my fork https://github.com/cambiata/react.hx.

I'm not experienced in javscript or node myself, so this is kind of a learning project for me...
But I would be glad to assist you, if I can!

Jonas

JSH

unread,
Jul 16, 2014, 10:21:40 PM7/16/14
to haxe...@googlegroups.com
Thank you Marc for kind guidance. 
I totally agree that there is no correct answer how to program it.
However, the information that I want to find is a guidance by advanced haxe users,
 as they know better in terms of process of more optimal approach on a project.
For about haxe, I think lack of complete tutorial (of which is alike the ' xxxx for dummies' book series) makes steep learning curve for 
beginners and experienced beginners who already know how to program.
Hope  eventually there will be this kind of tutorials, for sure it will be big help to spread haxe users. 

JSH

unread,
Jul 16, 2014, 10:35:05 PM7/16/14
to haxe...@googlegroups.com
Hi Jonas, 

Thank you for the links and kind words. Indeed these are good examples to look inside. 
Now I'm studying how to use externs and external javascript apis.  :)
It's difficult but interesting and fun. 

Steve 
Message has been deleted

Jesus Boadas

unread,
Jul 17, 2014, 9:15:01 AM7/17/14
to haxe...@googlegroups.com
I have a big haxe/js/php-neko application running on a production server with the wonderful jquery extern,
I was thinking of putting together an example to github but I am short in time so It's not gonna happen any time soon,
let me explain what I did.

Basically I foud that the singleton pattern works very well with single page applications,
In the client, I have a class that manage all my routes:

public function mainRouter(routeOrg:String) {
      
        var splitRoute = routeOrg.split("/");
        var route:String = splitRoute[0];
      
        if (!loginController.canUserLog(route)) {
            change("#");
            loginController.cleanSession(); <-- If you want authenticated users
            loginController.drawUi();
        }else {
            switch (route) {
                case "#main" :
                    changeState(route);
                case "#page-A" :
                    changeState(route);
                case "#page-B" :
                    changeState(route);
                case "#page-C" :
                    changeState(route);
                case "... etc" :          
 
                default :          
                    changeState("#main");
                    mainController.drawUi();
            }
        }
    }
   
   
    public function changeState(state:String) {
        Browser.window.history.pushState(null, null, estado);
    }

so with these routes I have only one html page and all I do is render the content into the page according to te route, also with this pattern I manage make my application multilanguage I use Bootstrap and FontAwesome for all my basic ui needs and svg for more complex ui requirements, with JQuery to manipulate the html and the svg's dom.

To comunicate with the server I use haxeRemote and the server have a class that handle all the requests:

static function main() {
    var database: Database = new Database();
    aaaApi = new aaaApi();
    bbbApi = new bbbApi();
    cccApi = new cccApi();
    dddApi = new dddApi();
    var ctx = new Context();
    ctx.addObject("aaaApi", aaaApi);
    ctx.addObject("bbbApi", aaaApi);
    ctx.addObject("cccApi", aaaApi);
    ctx.addObject("dddApi", aaaApi);
        
    if( haxe.remoting.HttpConnection.handleRequest(ctx) )
        return;
    // If the server can't handle the request print this.
    Lib.print("Cant handle request");
        Manager.cleanup();
  }  


In the server I mainly use php but if I have my own server I use Tora/Neko for my database I use MySql

Also I try ti keep everything simple and modular for make it easy to revisit.

Also you can do a search in github  there are some excelent libraries like Detox from Jason O'Neal

https://github.com/jasononeil/detox

and the good work of many haxers around the world, just keep searchin in github, you can get there all the answers.

In the outdated Haxe books you can find examples that still works well with these targets.

Hope this could help.
Best Regards

Philippe Elsass

unread,
Jul 17, 2014, 9:30:03 AM7/17/14
to haxe...@googlegroups.com
I prefer vanilla-js to jquery :P


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe

Juraj Kirchheim

unread,
Jul 17, 2014, 9:46:06 AM7/17/14
to haxe...@googlegroups.com
Vanilla JavaScript is great, but you may need to add plugins for IE8
and FF 3.5 support (so called polyfills) ;)
If you're going down that road, this is a great reference by the way:
http://caniuse.com/

Best,
Juraj

Philippe Elsass

unread,
Jul 17, 2014, 10:23:12 AM7/17/14
to haxe...@googlegroups.com
Yes, caniuse and http://www.quirksmode.org/, but nowadays there aren't too many limitations in IE8+ browsers.


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe

Juraj Kirchheim

unread,
Jul 17, 2014, 11:48:46 AM7/17/14
to haxe...@googlegroups.com
That *heavily* depends on what you are doing.

In some market segments IE8's share still goes up to 20% and IE8
really is very far from proper standard support. For example
querySelector and family works only for a subset of the spec,
Array.prototype.forEach and family are not defined, firstElementChild
and nextElementSibling don't work. I would call that very limited.
Then you have Chrome/Safari exposing many drafts with vendor prefixes
only and so on and so forth (both using the webkit prefix, but
sometimes using it in different places). And Firefox 3.5 is one of the
last without automatic updates, and therefore also occasionally hits
you, which is great since prior to 6.0 calling addEventListener
without an argument for useCapture will blow up in your face.

I don't mean to put down your enthusiasm, let alone suggest that any
JS library is particularly great, but the fact is that JavaScript is
still a *very* heterogeneous platform if you look at it accross the
board. Web developers should acknowledge this fact.

Best,
Juraj

Jesus Boadas

unread,
Jul 17, 2014, 12:26:06 PM7/17/14
to haxe...@googlegroups.com
I preffer vanilla javascript too over any library/framework but I
never used jquery in the past so I think it was time to learn
something new, also I like to code javascript in Haxe for the strong
typing and to avoid the javascript weirdness like the scope and the
prototypical inheritance. My project was done in the first time using
Flex (shame Adobe) and in the time it works flawlessly in all
browsers. I was rewriting it with HaxeAsWing but to avoid the flash
dependency I have to re-think the client part, also test some
AngularJS/Backbone/DurandalJS and some others MV** frameworks but they
doesn't appeal to me. I found a perfect javascript workflow with Haxe.
If tomorrow the www consortium drops javascript for any other
"whatever", I hope Haxe gonna have a target for that whatever :) .
> You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.
> For more options, visit https://groups.google.com/d/optout.



--
Jesus Boadas
jbo...@gmail.com
Reply all
Reply to author
Forward
0 new messages