Promise-like Syntax
Use familiar .then() syntax for reactive streams. If you know Promises, you already know Pipel-React.
Promise-like Reactive Streams for React
Simple, powerful, and elegant reactive programming with familiar Promise syntax
import { usePipel } from 'pipel-react'
function Counter() {
const [count, count$] = usePipel(0)
return (
<div>
<p>Count: {count}</p>
<button onClick={() => count$.next(count + 1)}>Increment</button>
</div>
)
}npm install pipel-react pipeljsyarn add pipel-react pipeljspnpm add pipel-react pipeljsconst [data, setData] = useState(null)
const [loading, setLoading] = useState(false)
const [error, setError] = useState(null)
const fetchData = async () => {
setLoading(true)
try {
const res = await fetch('/api/data')
setData(await res.json())
} catch (err) {
setError(err)
} finally {
setLoading(false)
}
}const { data, loading, error } = useFetch('/api/data', {
immediate: true,
})