1.1.1 • Published 7 years ago

observable-fetch v1.1.1

Weekly downloads
16
License
MIT
Repository
github
Last release
7 years ago

observable-fetch

RxJS Observable wrapped around the WHATWG Fetch API.

NPM version Build Status

Installation

$ yarn add observable-fetch

Alternatively using npm:

$ npm i observable-fetch --save

Usage

This library is especially built to be complementary to redux-observable;

import fetch from 'observable-fetch';

// action creators
const fetchUser = username => ({ type: FETCH_USER, payload: username });
const fetchUserFulfilled = payload => ({ type: FETCH_USER_FULFILLED, payload });

// epic
const fetchUserEpic = action$ =>
  action$.ofType(FETCH_USER)
    .mergeMap(action =>
      fetch(`https://api.github.com/users/${action.payload}`)
        .map(response => fetchUserFulfilled(response))
    );

// later...
dispatch(fetchUser('torvalds'));

License

MIT © Robin van der Vleuten

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago