2.2.0 • Published 2 years ago

snar v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Reactive Object made simple.

Published on npm

Snar is a tiny library that helps creating simple yet efficient reactive objects.

import {ReactiveObject, state} from 'snar';

class MyObject extends ReactiveObject {
  @state() value;

  updated() {
    // Every time `value` changes,
    // this function is called as a reaction.
    // Do something...
  }
}

const obj = new MyObject();
obj.value = 'foo'; // <- makes the object reacts.

Installation

npm i -D snar

or

yarn add -D snar

Relation with Lit

Snar base class ReactiveObject was made by pruning ReactiveElement base class from @lit/reactive-element package of the Lit framework, and only keep the reactivity feature.
This implies:

  • You don't need Lit as a dependency to use this library. In fact Snar has no dependencies.
  • You can use it in both Node and Browser environment.
  • If you've used Lit before, you'll feel yourself at home because it shares the same syntax.
2.2.0

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago