Skip to content

A Content Watcher is an object that contains some value. All time value changes a callback is triggered. Useful to link proccess and services via callback.

License

Notifications You must be signed in to change notification settings

enriquerene/content-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Content Watcher

A Content Watcher is an object that contains some value. All time value changes a callback is triggered. Useful to link proccess and services via callback.

Table of Contents

Support

If you need some help or found bug you can open an issue.

Installation

There are some installation ways. You can choose the best way for you.

NPM (recommended)

This way requires NodeJS installed:

$ npm install content-watcher

or using Yarn

$ yarn add content-watcher

Git

Clone the repo into your project:

$ git clone https://github.com/enriquerene/content-watcher.git

Zip

Dowload the package and uncpack it into your project: Dowload ZIP

Usage

Here we cover how to properly use Content Watcher library. The ContentWatcher instance requires a function as first argument and optionally can receive a second argument used as custom inital content. The default content is null. Let's see some examples:

Callback

Set a callback and implement the class:

import ContentWatcher from 'content-watcher';

const updateCallback = (_v) => { console.log(_v) };
const contWat = new ContentWatcher(updateCallback);

console.log(contWat.content); // null
contWat.content = 'final content'; // console logs 'final content'

Custom Initial Content

It accepts a second argument used as custom initial value:

import ContentWatcher from 'content-watcher';

const updateCallback = (_v) => { console.log(_v) };
const contWat = new ContentWatcher(updateCallback,  'initial content');

console.log(contWat.content); // 'initial content'
contWat.content = 'final content'; // console logs 'final content'

Plan

Some features what are expected for future versions:

  • support for custom handler for different content types;
  • official TypeScript version; Feel free to suggest features for futures versions, just open an issue.

Contribute

If you have something good to share in this project, you are welcome. Just do a pull request with your code.

Author

You can find more projects from ContentWatcher's author. Learn more about in (https://enriquerene.com.br)[https://enriquerene.com.br].

About

A Content Watcher is an object that contains some value. All time value changes a callback is triggered. Useful to link proccess and services via callback.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published