1.0.3 • Published 8 months ago

@marufzak/observable v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Observable

A lightweight reactive programming library for JavaScript and TypeScript.

Features

Basically everything you can do with builtin Proxy.

  • Create observable objects and functions
  • Track property access, modification, and deletion
  • Monitor function calls and method invocations
  • Build reactive systems with minimal overhead
  • TypeScript support with full type definitions

Installation

npm install @marufzak/observable

Usage

import { createObservable } from "@marufzak/observable";

const user = {
    name: "John",
    age: 30,
};

function observer(event) {
    console.log(`[${event.type}]`, event);
}

const observableUser = createObservable(user, observer);

observableUser.name = "Jane"; // Triggers set trap
console.log(observableUser.age); // Triggers get trap

Examples

Check out the examples directory for more usage examples.

License

MIT © Ma'ruf Zakirov

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago