0.0.2 • Published 1 year ago

@christopy/x-data v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

X-Data

X-Data is an agnostic reactivity solution for any framework.
It allows you to easily define reactive data, and automatically update your application whenever that data changes.

Installation

You can install X-Data using npm or yarn:

npm install @christopy/x-data
yarn add @christopy/x-data

Usage

First, import XData into your application:

import XData from "@christopy/x-data";

Then, define your data as an object, and pass it to XData:

const data = XData({
  name: 'John',
  age: 30,
});

Now, you subscribe to changes in your data by calling the subscribe method with the name of the property you want to subscribe to, and a callback function:

function onNameChange(name) {
  console.log(name);
}
data.subscribe('name', onNameChange);

Whenever the value of name changes, the callback function will be called with the new value.

You can also unsubscribe from changes in your data by calling the unsubscribe method with callback function:

data.unsubscribe(onNameChange);

License

X-Data is released under the MIT License.

0.0.2

1 year ago

0.0.1

1 year ago