prop - PronabM/State.js GitHub Wiki
prop
Objective
This acts as getter and setter. If the function is called by passing only one argument, it retrieve the value associated with the property; If the same function is called using two parameters, first one being the property and second one being the value, then the value is set for the property and the handlers are called(if any) which got registered using the on function.
Current Status
The getting and setting is working fine but I am yet to implement the onChange handlers. The current situation demands for a second core
to be present so that we could preserve the changes as required.
Implementation
We are splitting the property with Dot('.') and traversing to the required location and setting or getting the value.
myState.prop('range.type');
// Output
{
absolute: true
}
myState.prop('visible', true);
myState.getState();
//Output
{
range:{start: 1, end: 5}
visible:true
}