This package has been deprecated

Author message:

use rescript-use-sync-external-store instead

rescript-use-subscription

0.1.2 • Public • Published

rescript-use-subscription

This is a zero-cost ReScript binding package for use with use-subscription

Usage

Usage is essentially the same as the javascript package:

let {useSubscription} = module(UseSubscription)

@react.component
let make = () => {
  let options = React.useMemo(() => {
    UseSubscription.getCurrentValue: () => Some(1),
    subscribe: callback => {
      callback(. Some(1))

      (.) => ()
    },
  })
  let val = useSubscription(options)

  <div>{val->Belt.Option.mapWithDefault(React.null, React.int)}</div>
}

Uncurried functions are used to eliminate overhead from the ReScript generated output.

Package Sidebar

Install

npm i rescript-use-subscription

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

4.58 kB

Total Files

8

Last publish

Collaborators

  • illusionalsagacity