1.0.6 • Published 5 years ago

rkdrnf-watcher v1.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

rkdrnf-watcher

This library provides base class for watching properties inside.

Usage

class Component offers watch() and step() method to watch it's own property and represent single step of tracking. By calling step() repetitively according to any refresh cycle you intended, you can mimick variable tracking feature in those UI Framework such as React or Angular

API

watch(propName, callback)

step()

Example

import { Component } from "rkdrnf-watcher";

class MyComponent extends Component {
    ...
    constructor() {
        super();
        this.clickCount = 0;
        this.watch("clickCount", (prop, changes) => {
            console.log(`${prop} old: ${changes.old}, new: ${changes.val}`);
        });
    }
    
    onClickUI() {
        this.clickCount++;
    }

    onEachFrame() {
        this.step();
    }
}

Test

$ npm test

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago