@watch-state/decorators
TypeScript icon, indicating that this package has built-in type declarations

1.3.0-alpha.0 • Public • Published
Watch-State logo by Mikhail Lysikov

  @watch-state/decorators

 
NPM downloads downloads license

State management decorators based on watch-state

Install

npm

npm i @watch-state/decorators

yarn

yarn add @watch-state/decorators

Usage

You can use one of the next decorators

import { Watch } from 'watch-state'
import { state, cache, event } from '@watch-state/decorators'

class Counter {
  // fields
  @state accessor value = 1

  // accessors
  @cache get square () {
    return this.value ** 2
  }

  // methods
  @event tick () {
    this.value++
  }
}


const counter = new Counter()

new Watch(() => console.log(counter.value, counter.square))
// console.log(1, 1)

counter.tick()
// console.log(2, 4)

Package Sidebar

Install

npm i @watch-state/decorators

Weekly Downloads

2

Version

1.3.0-alpha.0

License

MIT

Unpacked Size

10.4 kB

Total Files

30

Last publish

Collaborators

  • deight