angular.haxe released

179 views
Skip to first unread message

Heinz Hölzer

unread,
Aug 26, 2014, 4:37:51 PM8/26/14
to haxe...@googlegroups.com
Hey guys,

i just released angular.haxe on haxelib which is a library that helps using angular.js together with haxe. It's still very alpha and some features and apis are missing. I would love to get some opinions and ideas for improvements for it.


best,
h

Marcelo de Moraes Serpa

unread,
Aug 26, 2014, 5:00:21 PM8/26/14
to Heinz Hölzer, haxe...@googlegroups.com
Hi Heinz,

That’s very interesting! I’m starting to look into Angular now after spending some time with Backbone and a custom framework some of my colleagues*[1]. I’m OK with pure Javascript, but I prefer a cleaner approach. Coffeescript has been helping me with it, I think Haxe could have the edge here, even if more verbose, because of the type-safety, the macro subsystem and of course, potentially portable code, specially for large applications.

It’d be really nice to have a portion of the README comparing the main aspects of Angular with pure js vs Haxe, highlighting possible benefits added by Haxe. 

Keep up the good work,


-- 
Marcelo
--
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.

Chris Anderson

unread,
Aug 26, 2014, 5:25:20 PM8/26/14
to haxe...@googlegroups.com
Appreciate this Heinz, will be taking a peek asap.

Heinz Hölzer

unread,
Aug 26, 2014, 5:44:50 PM8/26/14
to haxe...@googlegroups.com, heinz....@googlemail.com
thx for the feedback, i already started to add some docs to highlight differences.

Bohdan Makohin

unread,
Sep 7, 2014, 6:15:41 PM9/7/14
to haxe...@googlegroups.com
Hi Heinz,

Very nice ideas in library. Especially I liked the way you solved DI integration (@:injectionName). Some time ago I've made little example integration with AngularJs on my own (https://github.com/ajukraine/hxangular). Nothing special though. I've utilized the JS like approach for injection. Each c-tor (for Controller or Service) has metadata @inject, which describes dependencies. 

Btw how you handle injection of constants?

Вівторок, 26 серпня 2014 р. 23:37:51 UTC+3 користувач Heinz Hölzer написав:

Heinz Hölzer

unread,
Sep 8, 2014, 9:43:35 AM9/8/14
to haxe...@googlegroups.com
Hi Bohdan,

no there is no good solution for constant injection currently, i could integrate it in some way or another, but you would lose some compile time safety. Do you think that's an important feature? (i never had the need to use it with haxe). There is also no support for service, because in haxe you don't really need it because you can just use myModule.factory(MyClass.new) instead of the service shortcut.

best,
heinz

Bohdan Makohin

unread,
Sep 9, 2014, 2:03:35 PM9/9/14
to haxe...@googlegroups.com
Heinz,

regarding constant injection, for example, I use them to configure different endpoint URLs of external web services. The service support is important, because (AFAIK) it provides the ability to control object's lifetime. Service is instantiated only once (first time when it's requested) and then it lives in DI container during whole application lifetime. However factory creates new object each time, when it's called. So almost always we need services to live as singletons (one per container), so why should we use factories for that?

However in general, the Haxe externals/support for Angular is very important contribution to Haxe community/platform. But as for now we have 3 attempts in this direction and no-one is fully-fledged. That's is sad :(

Понеділок, 8 вересня 2014 р. 16:43:35 UTC+3 користувач Heinz Hölzer написав:

Heinz Hölzer

unread,
Sep 10, 2014, 4:41:30 AM9/10/14
to haxe...@googlegroups.com
Are you really sure about factory creating a new object every time? I cannot reproduce that, in my example it's called only once.

Heinz Hölzer

unread,
Sep 10, 2014, 4:43:34 AM9/10/14
to haxe...@googlegroups.com
See section Factory Recipe on https://docs.angularjs.org/guide/providers

Bohdan Makohin

unread,
Sep 10, 2014, 7:03:13 AM9/10/14
to haxe...@googlegroups.com
Well, you must be right then.

Note: All services in Angular are singletons. That means that the injector uses each recipe at most once to create the object. The injector then caches the reference for all future needs.

And yes, factories/service are just syntax sugar around providers:
The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe. 

Середа, 10 вересня 2014 р. 11:43:34 UTC+3 користувач Heinz Hölzer написав:

Heinz Hölzer

unread,
Sep 10, 2014, 11:35:06 AM9/10/14
to haxe...@googlegroups.com
By the way to avoid the naming of constants you can use abstracts:

abstract ServiceUrl(String) to String {
public function new (url:String) this = url;
}


class Config {
public var serviceUrl:String;
public function new (serviceUrl:ServiceUrl) {
this.serviceUrl = serviceUrl;
}
}

myModule.factory(function () return new ServiceUrl("http://www.mybackendserviceurl.com")) // there is currently a compiler bug with abstracts which doesn't allow ServiceUrl.new.bind("http://www.mybackendserviceurl.com")
Reply all
Reply to author
Forward
0 new messages