All Projects → vesparny → rxhr

vesparny / rxhr

Licence: MIT license
Tiny Observable based HTTP client for browsers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rxhr

Axios Tutorial
axios实例应用及源码剖析 - xhr篇 (走心教程)
Stars: ✭ 219 (+1360%)
Mutual labels:  xhr
react-nonav
Experimental React Native declarative navigation
Stars: ✭ 58 (+286.67%)
Mutual labels:  rxjs
ccex-api
Cryptocurrency exchanges realtime api wrapper
Stars: ✭ 29 (+93.33%)
Mutual labels:  rxjs
I18next Xhr Backend
[deprecated] can be replaced with i18next-http-backend
Stars: ✭ 252 (+1580%)
Mutual labels:  xhr
gitlab-teams
🦊 Follow merge requests (&more) like a boss 🦊
Stars: ✭ 38 (+153.33%)
Mutual labels:  rxjs
observable-profiler
Tracks new & disposed Observable subscriptions
Stars: ✭ 41 (+173.33%)
Mutual labels:  rxjs
Xhr Mock
Utility for mocking XMLHttpRequest.
Stars: ✭ 188 (+1153.33%)
Mutual labels:  xhr
ng-effects
Reactivity system for Angular. https://ngfx.io
Stars: ✭ 46 (+206.67%)
Mutual labels:  rxjs
vuse-rx
Vue 3 + rxjs = ❤
Stars: ✭ 52 (+246.67%)
Mutual labels:  rxjs
firebase-rxjs
Firebase with Observables, Type Checking of Schema, Zone.js aware and Angular ready.
Stars: ✭ 17 (+13.33%)
Mutual labels:  rxjs
ts-action-operators
TypeScript action operators for NgRx and redux-observable
Stars: ✭ 34 (+126.67%)
Mutual labels:  rxjs
rdeco
响应式对象编程库,从时间和空间上解耦你的代码
Stars: ✭ 54 (+260%)
Mutual labels:  rxjs
thruway.js
RxJS WAMPv2 Client
Stars: ✭ 28 (+86.67%)
Mutual labels:  rxjs
Pending Xhr Puppeteer
Small tool to wait that all xhr are finished in puppeteer
Stars: ✭ 227 (+1413.33%)
Mutual labels:  xhr
observer-spy
This library makes RxJS Observables testing easy!
Stars: ✭ 310 (+1966.67%)
Mutual labels:  rxjs
Xmlhttprequest
XMLHttpRequest.js - Standard-compliant cross-browser XMLHttpRequest object implementation
Stars: ✭ 211 (+1306.67%)
Mutual labels:  xhr
learnrxjs
Русскоязычная документация RxJS
Stars: ✭ 20 (+33.33%)
Mutual labels:  rxjs
fullstack-typescript
A demo project of a full stack typescript application
Stars: ✭ 28 (+86.67%)
Mutual labels:  rxjs
rxjs-sort-visualization
sorting algorithm visualization build by Rxjs 🐠
Stars: ✭ 16 (+6.67%)
Mutual labels:  rxjs
ngx-translate-module-loader
Highly configurable and flexible translations loader for @ngx-translate/core
Stars: ✭ 31 (+106.67%)
Mutual labels:  rxjs

rxhr

A tiny Observable based HTTP client

Travis Code Coverage David npm npm JavaScript Style Guide MIT License

The current size of rxhr/dist/rxhr.umd.min.js is:

gzip size

Install

This project uses node and npm. Go check them out if you don't have them locally installed.

$ npm i rxhr

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import rxhr from 'rxhr'

// using CommonJS modules
var rxhr = require('rxhr')

The UMD build is also available on unpkg:

<script src="https://unpkg.com/rxhr/dist/rxhr.umd.js"></script>

You can find the library on window.rhxr.

Usage

import rxhr from 'rxhr'

const req$ = rxhr({
  method: 'get',
  responseType: 'json',
  url: 'https://jsonplaceholder.typicode.com/posts'
})
.subscribe(
  res => res.json().forEach(e => console.log(e.title)),
  err => console.log(err),
  () => console.log('completed')
)

// abort request
req$.unsubscribe()

It's easy to combine with rxjs

const req$ = rxhr({
  method: 'get',
  responseType: 'json',
  url: 'https://jsonplaceholder.typicode.com/posts'
})

const sub$ = Rx.Observable
.timer(0, 1000)
.switchMap(() => Rx.Observable.from(req$))
.map(res => res.json())
.subscribe(
  res => console.log(res.length),
  err => console.log('err', err),
  () => console.log('completed')
)

It supports blob request type

const req$ = rxhr({
  method: 'get',
  responseType: 'blob',
  url: 'https://avatars2.githubusercontent.com/u/82070?v=3&s=460'
})

const sub$ = Rx.Observable
.timer(0, 1000)
.take(3)
.switchMap(() => Rx.Observable.from(req$))
.map(res => res.blob())
.subscribe(
  blob => {
    const fr = new FileReader();
    fr.onload = function(e) {
      const img = new Image(); // width, height values are optional params
      img.src = e.target.result
      document.body.appendChild(img)
    }
    fr.readAsDataURL(blob);
  },
  err => console.log('err', err),
  () => console.log('completed')
)

Tests

$ npm run test

MIT License © Alessandro Arnodo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].