New answers tagged

1

First thing, you're right about HttpRequest and the oddness of having to pass manually body and url . To improve the code, I would suggest to chose a programming paradigm, and to stick to it: example in OOP: class HttpRequest<TResult> { constructor(private method: HttpMethod, private url: string, private body?: any) {} request():Promise<...


3

I'm not familiar with Promise from JavaScript and this is quite a complex flow, so hopefully I didn't miss much. Let's just review the flow a bit new Promise<>(new Promise.Executor<Integer>() { @Override public void execute(Promise.Action<Integer> action) { // Perhaps do something asynchronous and then: action....


3

Mutating built-in prototypes is not a good idea. It's not only inelegant, it can also lead to conflicts when other scripts on the page expect the prototypes to be unmutated. (It can even damage future attempts to integrate functionality officially, if enough sites use the bad code.) Instead of using Element.prototype, create your own class, and put methods ...


Top 50 recent answers are included