@replygirl/proxyable-behavior-subject
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

ProxyableBehaviorSubject

A BehaviorSubject that returns a Proxy. All the reactivity, without having to call next!

Note: I literally haven't tested this

Installation

yarn add @replygirl/proxyable-behavior-subject

Usage

import ProxyableBehaviorSubject from '@replygirl/proxyable-behavior-subject'

const foo = new ProxyableBehaviorSubject({ bar: true })
const f = foo.proxy
console.info(f.bar, foo.value.bar) // true, true

// set with the proxy and the value will stay in sync
f.bar = true
console.info(f.bar, foo.value.bar) // true, true

// call next as usual and the proxy will stay in sync
foo.next({ bar: false })
console.info(f.bar, foo.value.bar) // false, false

// use the p alias to skip assignment
foo.p.bar = true
console.info(foo.p.bar, foo.value.bar) // true, true

License

ISC (c) 2020 replygirl

Dependencies (1)

Dev Dependencies (2)

Package Sidebar

Install

npm i @replygirl/proxyable-behavior-subject

Weekly Downloads

0

Version

0.2.2

License

ISC

Unpacked Size

218 kB

Total Files

9

Last publish

Collaborators

  • imogen