@brave-js/inscriber
A Simple Javascript Class which is carved out with some features to offer the property bindings for the instances

Installation
yarn add @brave-js/inscriber
Design
Inscriber
a distinct javascript class
Inscriber Class
-
The scope of the API works only within the current object / instance of the class
-
Allows addition & deletion to property binding list
-
Property binding change event is delegated via the setters / getters
-
Allows deletion of computed property
-
Computed Property value is cached. The callback is never called unless the cache is reset
-
Last but not least, you can force enable / disable cache. Default is enable cache
compute
Enables the usage of computed property within the current object / instance of the class
Parameters
-
name
name of the computed property
-
properties
array of properties that exists in the current object
-
method
callback function which to calculate the value of the computed property
Usage
import Inscriber from '@brave-js/inscriber';
class Person extends Inscriber {
constructor(obj) {
super();
this.firstName = obj.firstName;
this.lastName = obj.lastName;
return this;
}
}
var person = new Person({
firstName: 'John',
lastName: 'Doe'
});
person.compute('fullName', ['firstName', 'lastName'], function() {
return `${this.firstName} ${this.lastName}`;
});
person.fullName
person.firstName = 'Mr';
person.lastName = 'Rob';
person.fullName
destruct
Destructs the computed property within the current object / instance of the class
Parameters
name
name of the computed property
Usage
import Inscriber from '@brave-js/inscriber';
class Person extends Inscriber {
constructor(obj) {
super();
this.firstName = obj.firstName;
this.lastName = obj.lastName;
return this;
}
}
var person = new Person({
firstName: 'John',
lastName: 'Doe'
});
person.compute('fullName', ['firstName', 'lastName'], function() {
return `${this.firstName} ${this.lastName}`;
});
person.fullName
person.destruct('fullName');
person.firstName = 'Mr';
person.lastName = 'Rob';
person.fullName
set
Sets the value for the property in the XPATH within the current object / instance of the class
Parameters
Usage
import Inscriber from '@brave-js/inscriber';
Inscriber.name = {};
Inscriber.set('name.firstName', 'Mr');
Inscriber.set('name.lastName', 'Rob');
get
Retrieve the value for the property in the XPATH within the current object / instance of the class
Parameters
xpath
XPATH of the property
Usage
import Inscriber from '@brave-js/inscriber';
Inscriber.name = {firstName : 'John', lastName: 'Doe'};
Inscriber.get('name.firstName');
Inscriber.get('name.lastName');
toggle
Disables the cache for all computed property of the binding property. Will be useful to reset cache at any point of time.
Parameters
property
name of the bindings
Usage
firstName
, lastName
, street
, city
are binding properties
reset
Enables the cache for the computed property. Will be useful to read the old value & new value after a change
Parameters
name
name of the computed property
Usage
fullName
, address
are computed property for binding properties firstName
, lastName
, street
, city