Skip to content

r7kamura/cycle-fetcher-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cycle-fetcher-driver

A Cycle.js Driver for making HTTP requests using stackable-fetcher.

Install

npm install @r7kamura/cycle-fetcher-driver

Usage

import Cycle from '@cycle/core';
import { h, makeDOMDriver } from '@cycle/dom'
import { makeFetcherDriver } from '@r7kamura/cycle-fetcher-driver';

Cycle.run(
  ({ HTTP }) => {
    const url = 'http://example.com';
    const request$ = Cycle.Rx.Observable.just({ method: 'GET', url });
    const vtree$ = HTTP
      .filter((response$) => response$.request.url === url)
      .mergeAll()
      .map(({ body }) => body)
      .startWith('Loading...')
      .map(text => h('h1', text));
    return {
      DOM: vtree$,
      HTTP: request$
    };
  },
  {
    DOM: makeDOMDriver('body'),
    HTTP: makeFetcherDriver()
  }
);

image

About

A Cycle.js Driver for making HTTP requests using fetcher.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published