Rx-Ajax
Super simple (but advanced) ajax reactive library. Using RxJS. Supports sending files.
Installation
$ npm install rx-ajax
Usage
; let http = ;let data = number: 5;let options = {}; http;
Shortcuts
http;http;http;
Options
jsonp
: name of callback for jsonp requests, whentrue
is given callback name is used. Default isfalse
jsonPrefix
: prefix for json requests. Read more here. Default isnull
mimeType
: Default isnull
headers
: List of headers to be send to server. Default is{}
files
: List of files to be send to server. Default is[]
Queue
By default all your requests are called from queue one by one, so there is always just one request running (or zero). Inspiration is from this article http://blog.alexmaccaw.com/queuing-ajax-requests.
You can disable this feature with ImmediateQueue
:
;; let http = queue: ;
Events
httpsend; httpafterSend; httpsuccess; httperror;
Extensions
Sometimes it will be better to register whole group of events and this group is called extension.
;; public : void // todo public : void // todo public : void // todo public : void // todo // ... http;
Built in extensions
Links
This extension listen for all click events on A
tags with ajax
class and call them via ajax.
; http;
Loading
; http;
Offline
This extension tests if your favicon.ico is accessible. You can change test destination by specifying Offline's constructor argument.
; http; httpconnected; httpdisconnected;
Redirect
If your server sends json data with redirect variable, then you will be redirected to address in this variable.
; http;
Snippets
If there is snippets
object in response data with html id and content pairs, then this extension will iterate through
this object, find element in page with given id and change content of given element into the one from response data.
; http;
Known limitations
- All non ASCII chars (eg. letters with diacritics) in file names are converted to ASCII chars before uploading.