Skip to content

Andarist/use-callbag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-callbag

Use callbag as React hook.

Example

import interval from 'callbag-interval'
import map from 'callbag-map'
import pipe from 'callbag-pipe'
import useCallbag from 'use-callbag'

export default function Counter({ initialCount }) {
  const count = useCallbag(initialCount, () =>
    pipe(
      interval(1000),
      map(i => initialCount + i + 1),
    ),
  )
  return <span>{`Counter: ${count}`}</span>
}