title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
|
Tuesday, June 15, 2021 | |
Okay, one thing I hate in JavaScript code is all the code around AJAX requests. jQuery has a wrapper. And AngularJS has a wrapper. And RxJS has a wrapper. And... Why don't we just use XMLHttpRequest? Then our services, which are often fairly UI-templating-agnostic already, can live anywhere we want. There are at least two good reasons... The first is to handle JSONP. I'm ignoring that for now. The second is to handle async code in a manner that's conventional for each templating engine.
For the most part, however, you can pass the data event back into the templating system's change detection scheme fairly easily. So I wanted to write a quick I'll try to edit this as I make changes. Comments welcome. The bottom line, though, is that this is not difficult code. Why we thought we needed wrappers to make AJAX calls I'll never know. The longer you can resist context-specific code, like library-specific wrappers, the longer your original code can live. (See Exhibit VanillaJS (or the more useful, but strangely mascoted, competing Vanilla JS project).) Yes, this is, in contrast to my original goals, in TypeScript. It's a pretty easy port. But seriously, you should be using TypeScript.
Labels: code, javascript, noteToSelf, typescript posted by ruffin at 6/15/2021 10:30:00 AM |
|
| |
All posts can be accessed here: Just the last year o' posts: |
||||||||||||||||||||||
|