0.5.3 • Published 4 years ago

widok v0.5.3

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

Widok

> Uses @vue/reactivity part of vue lib
> Supports vue-devtools
> Minimal overhead
> Allow directly state manipulation (without using mutation)

Usage

// Widok instance
import { createWidok } from 'widok';
export const widok = createWidok();

// main app
const app = createApp(App);
app.use(widok);

// store
class Shop {
	cart = [];

	get getCount() {
		return this.cart.length;
	};

	addToCart(addItem: Item) {
		this.cart.push(addItem);
	}

	@Action()
	async buy() {
		await fetch('cart/buy', this.cart);
		this.cart.length = 0;
	}
}

export const shop = widok(Shop);

// usage
import { shop } from './shop';

shop.addToCart({
    name: 'Laptop',
    price: 200
});
// will emit Patch event

shop.cart.length = 0;
// will also emit Patch event

API

createWidok

Creates Widok instance and return function(StoreClass, name?)

name argument is optional, to overwrite default name extracted from function.name (class name)

@Patch(name?)

Decorator, needed only to overwrite default name (extracted from function.name)

@Action(name?)

Decorator, if the method performs any async operation should be decorated with (it is only for proper devtools logging).

name argument is optional, to overwrite default name extracted from function.name

Events

  • ActionEvent = some async activities (trigger PatchEvens or SetEvents)
  • PatchEvent = grouped values change
  • SetEvent = directly value change
0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

1.0.0

6 years ago