Ready for testing: vibe.d 0.7.26-alpha.3
Sebastiaan Koppe via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 30 20:07:34 PDT 2015
On Friday, 30 October 2015 at 21:03:21 UTC, Brad Anderson wrote:
> On Friday, 30 October 2015 at 16:16:11 UTC, Sebastiaan Koppe
>> I really have to say I fail to see any value in that JS
>> interface generation feature. The idea is nice, but it needs
>> adapters to common ajax libraries, instead of homegrown stuff.
>
> I'm not really a web developer. Do you have any examples of
> what you mean?
In frontend development people are likely to use the same
framework/library they used last time, in order to speed up
development. Besides know-how, most of that stuff is
battle-tested.
There are lots of quirks with ajax and getting everything right
takes time. Take for instance the variety of errors (that nobody
seems to check on): bad request, exception on server, cors
errors, wrong response type, connection timeout (server down), no
internet.
(I live in China and the great firewall leaves a lot of websites
in a half working state. There are only a few sites that catch
these failures and notify the user, everything else just freezes.)
I personally am a big fan of React and RxJS, so if I do anything
with ajax, it's convenient to use ajax extensions for RxJS, since
I am using it anyway.
So, given that it takes time to develop your own ajax lib, and
people already use frameworks/libraries that have good ajax
support, it makes no sense to develop your own.
Instead, what you want to do is generate code that uses one of
those libraries. Here is an example of how an ajax call looks
like using RxDom, an extension for RxJS:
```
import RxDom from 'rx-dom';
module.exports={
status: () =>
{
return RxDom.DOM.ajax(
{
url:"/api/v1/status",
method:"GET",
responseType:"json"
}).pluck('response');
},
//....
}
```
More information about the Digitalmars-d
mailing list