Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

cycle-fetch-driver

Cycle.js for the Fetch API

Subscribe to updates I use cycle-fetch-driver


Statistics on cycle-fetch-driver

Number of watchers on Github 27
Number of open issues 7
Average time to close an issue 1 day
Main language JavaScript
Average time to merge a PR about 5 hours
Open pull requests 1+
Closed pull requests 1+
Last commit over 3 years ago
Repo Created almost 4 years ago
Repo Last Updated almost 2 years ago
Size 20 KB
Organization / Authorcyclejs
Contributors3
Page Updated
Do you use cycle-fetch-driver? Leave a review!
View open issues (7)
View cycle-fetch-driver activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating cycle-fetch-driver for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Cycle Fetch Driver

A Cycle.js Driver for making HTTP requests, using the Fetch API.

Install

npm install @cycle/fetch

API

makeFetchDriver(scheduler: Scheduler) -> fetchDriver: function

Factory that returns a fetch driver. It takes an optional scheduler argument to pass into fromPromise.

Usage

Basics:

import 'whatwg-fetch' // polyfill if you want to support older browsers
import Cycle from '@cycle/core';
import { makeFetchDriver } from '@cycle/fetch';

function main(responses) {
  // ...
}

const drivers = {
  HTTP: makeFetchDriver()
}

Cycle.run(main, drivers);

Simple and normal use case:

function main({ DOM, HTTP }) {
  const HELLO_URL = 'http://localhost:8080/hello';
  const request$ = Rx.Observable.just(HELLO_URL);
  const vtree$ = HTTP
    .byUrl(HELLO_URL)
    .mergeAll()
    .flatMap(res => res.text()) // We expect this to be "Hello World"
    .startWith('Loading...')
    .map(text =>
      h('div.container', [
        h('h1', text)
      ])
    );

  return {
    DOM: vtree$,
    HTTP: request$
  };
}

Select all the responses for a certain key:

function main({ DOM, HTTP }) {
  const HELLO_URL = 'http://localhost:8080/hello';
  const request$ = Rx.Observable.just({
    key: 'hello',
    url: HELLO_URL
  });
  const vtree$ = HTTP
    .byKey('hello')
    .mergeAll()
    .flatMap(res => res.text()) // We expect this to be "Hello World"
    .startWith('Loading...')
    .map(text =>
      h('div.container', [
        h('h1', text)
      ])
    );

  return {
    DOM: vtree$,
    HTTP: request$
  };
}
cycle-fetch-driver open issues Ask a question     (View All Issues)
  • about 3 years Support Cycle.js Diversity
  • over 3 years clone the response
  • over 3 years Support @cycle/isolate
  • over 3 years Disambiguate the request interface
  • over 3 years Publishing to npm
  • over 3 years Investigate BehaviorSubject vs ReplaySubject
cycle-fetch-driver open pull requests (View All Pulls)
  • Add isolateSink and isolateSource to support cyclejs/isolate
cycle-fetch-driver list of languages used
Other projects in JavaScript