Created
November 12, 2018 18:06
-
-
Save reaktivo/d52cbcbbe7313700043fa3d0ccd34497 to your computer and use it in GitHub Desktop.
Callbag Subscription with React Hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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