iris
Sweet Promise-based XHR/JSONP library for browsers.
Last updated 8 years ago by killdream .
MIT/X11 · Repository · Original npm · Tarball · package.json
$ cnpm install iris 
SYNC missed versions from official npm registry.

Iris

Iris is a library for handling HTTP (through XMLHttpRequest) and JSONP requests in a more high-level way. It uses promises to allow for more declarative and flexible handling of the responses from either side.

// HTTP example
var http = require('iris').http

http.get('/user/profile')
    .timeout(10) // in seconds
    .ok(function(data){
       $('#user').html(data)
    })
    .timeouted(function(){
       dialog.error('The operation timed out.')
    })
    .failed(function() {
       dialog.error('Ooops, something went wrong.')
    })
    

// JSONP example
var jsonp = require('iris').jsonp

jsonp.get('/user/posts')
     .timeout(10)
     .ok(function(data) {
        $('#post-count').text(data.posts.length + ' posts.')
     })
     .timeouted(function() {
        dialog.error('The operation timed out.')
     })
     .failed(function() {
        dialog.error('Ooops, something went wrong.')
     })

Requirements and Supported Platforms

Iris depends on the following libraries:

Additionally, there's a dependency on the set of safely shim-able ECMAScript 5 features, which can be provided by a library like es5-shim.

Installing

  1. you'll need node.js and npm. As soon as you got your hands on those beautiful thingies, you can just run the following in your project's directory.

    $ npm install iris

  2. Then require iris in your script:

    var iris = require('iris')

    iris.http.get('/za/warudo')

  3. Then compile it (use --watch for added development-phase awesomeness):

    $ browserify your-script.js -o bundle.js

  4. Finally, just put it all in your page:

    <html> {{ ... }} <body> {{ lots of things may go here, too }} <script src="/path/to/bundle.js"></script> </body> </html>

Downloading

Iris is nicely hosted (and developed) on Github. You can [download the lastest snapshot][] or clone the entire repository:

$ git clone git://github.com/killdream/iris.git

Getting support

  • Use the Github tracker to report bugs or request features. Like a boss!

  • Fork, do your changes and send me a pull request if you want to~

  • For general support, you can send me an e-mail on quildreen@gmail.com

Licence

Iris is licensed under the delicious and permissive MIT licence. You can happily copy, share, modify, sell or whatever — refer to the actual licence text for less information:

$ less LICENCE.txt

Current Tags

  • 0.2.3                                ...           latest (8 years ago)

6 Versions

  • 0.2.3                                ...           8 years ago
  • 0.2.2                                ...           8 years ago
  • 0.2.1                                ...           8 years ago
  • 0.2.0                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.1                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (4)

Copyright 2014 - 2017 © taobao.org |