On Wednesday, 30 April 2014 at 03:09:43 UTC, Adam D. Ruppe wrote:
On Wednesday, 30 April 2014 at 02:43:43 UTC, Rikki Cattermole
wrote:
All I'm saying is, if you ever not want to write ajax code
again, Cmsed is your friend [1].
My web.d does some javascript generation too.
D:
import arsd.web;
class Foo : ApiProvider {
export int add(int a, int b) { return a+b; }
}
mixin FancyMain!Foo;
Javascript:
Foo.add(1, 2).get(alert); // calls alert(3) when it returns
The generated JS code creates an object with the same name as
the D class with all the export functions as methods that
return a proxy object, setting the arguments. You can then
modify it and eventually fire off the request with methods like
get, getSync, and getHtml which take a function to call with
the result.
Just one of the many things I miss when doing RoR instead of D
:(
We should probably work together on this sort of stuff! As we
seem to have similar ideas