Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One of the things that for some reason really confuses me about Dart even though it probably shouldn't is it's status as being full stack.

I really want to use AngularDart for the front end of an application I am using and I would like to use Rails for the back end as well as some static content. I can't seem to find an easy way to make that happen. In addition, how does Dart interact with existing JavaScript libraries?



You can find JS Interop docs at: https://www.dartlang.org/articles/js-dart-interop/

IMO integration is as straight-forward as it gets, basically just use a HTTP Client to call JSON services. Here's an AngularDart example for calling a REST backend: http://japhr.blogspot.com/2013/10/http-requests-in-angularda...

I've also created a JsonClient that provides a terse API for calling JSON services: https://github.com/dartist/json_client


So in theory it's as easy as using AngularDart and compiling the javascript and throwing that in my rails assets? I feel like I knew that and for some reason it blows my mind.


We use a similar stack except using TypeScript with Angular but keep the Rails backend.

Essentially your Angular code should boil down to one JS file, one CSS file and be hosted in an index.html. If you're dealing with modern browsers a bit of fiddling with the cross domain policy and the withCredentials flag will allow you to host the static assets anywhere (not the same domain as the Rails box).

Otherwise the easiest thing to do is compile into the /public folder of Rails. I wouldn't host in assets as you'll likely be using gulp / grunt so the compilation phase that Rails assets hosting provides will be done for you already.


After fighting and fighting with the asset pipeline I finally realized I could just use gulp to build to my public folder and completely avoid fucking with it. It was an amazing moment of clarity for me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: