@reix/rxjs-bits
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

rxjs-bits

Rxjs integration for the @reix/bits package.

Usage

This package requires both rxjs and @reix/bits as peer dependencies.

import { toSubjects } from '@reix/rxjs-bits'
import { BitFieldEmitter } from '@reix/bits'

const myEventCode = 2

const emitter = new BitFieldEmitter<number>()
const { on$, emit$, dispose } = toSubjects(emitter, myEventCode)

on$.subscribe(({ value, code }) => {
    console.log(`Fired with value ${value} and code ${code}`)
})

emitter.emit(myEventCode, 2) // Fired with value 7 and code 2

emit$.next({
    value: 7
}) // Fired with value 7 and code 2

emit$.next({
    value: 7,
    code: myEventCode | 4
}) // Fired with value 7 and code 6

// do cleanup
dispose()

Package Sidebar

Install

npm i @reix/rxjs-bits

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

26.5 kB

Total Files

7

Last publish

Collaborators

  • adrielus