observx
v1.0.4
Published
Tini-Tiny Observer creating library. Not even sure it achievs that goal but surely does something π
Readme
βββββββ βββββββ ββββββββ ββββββββ βββββββ βββ βββ βββ βββ
βββββββββ ββββββββ ββββββββ ββββββββ ββββββββ βββ βββ ββββββββ
βββ βββ ββββββββ ββββββββ ββββββ ββββββββ βββ βββ ββββββ
βββ βββ ββββββββ ββββββββ ββββββ ββββββββ ββββ ββββ ββββββ
βββββββββ ββββββββ ββββββββ ββββββββ βββ βββ βββββββ ββββ βββ
βββββββ βββββββ ββββββββ ββββββββ βββ βββ βββββ βββ βββ
ObservX :zap:
Tini-Tiny Observer creating library. Not even sure it achievs that goal but surely does something :laughing:
Installation π
$ npm i --save observxUsage π
const { subscribe } = require("observx")
var streamedData = subscribe([12, 323, 233], res => {
console.log("changed");
});
console.log(streamedData.currentData()); // [12, 323, 233]
streamedData.changeWith([2]);
console.log(streamedData.currentData()); // [2]
API π
subscribe(data[,onchangeCB])
the subscribe method takes one required argument which is the observables or the data and one optional callback which is called everytime any changes happens to the observer. It returns a observer
The callback onchangeCB will give a response argument which is a object consisting the data and the type of the data
{ data, newdata, typeOfData: typeof data }subcribe().changeWith(newData)
this method takes a argument with which it will change the existing data. It will return the newdata which is replaced with
subcribe().currentData()
It will simply return the current data (observables).
Note Still Need some refactoring and fixing for the APIs and the
subscribemethod π
