Skip to content

Instantly share code, notes, and snippets.

@reaktivo
Created November 12, 2018 18:06
Show Gist options
  • Select an option

  • Save reaktivo/d52cbcbbe7313700043fa3d0ccd34497 to your computer and use it in GitHub Desktop.

Select an option

Save reaktivo/d52cbcbbe7313700043fa3d0ccd34497 to your computer and use it in GitHub Desktop.
Callbag Subscription with React Hooks
import { useState, useEffect } from "react";
import { pipe } from "callbag-basics";
import subscribe from "callbag-subscribe";
export default fns => {
const [value, setValue] = useState(null);
useEffect(
() =>
pipe(
...fns,
subscribe(setValue)
),
fns
);
return value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment