Transform functions on objects to properties with the return type of the function.
type dataType = {
price: number,
qty: number,
total(): number
};
// The transformed type after using ObservedData<T>
type dataTypeAsObservedData = {
price: number,
qty: number,
total: number
};
Plain javascript object.
Gets the return type of a function.
Any function definition.
Key used to attach an observable instance to an object.
Creates a reactive property on a specified object.
For a property to be considered reactive it needs to be proxied with a getter/setter and also have an associated Observable instance.
const obj = {};
defineReactiveProperty(obj, 'number', new Observable(99));
// Note that even though the value is proxied you can still access it as you normally access properties.
console.log(obj.number) // output: 99
obj.number = 105;
console.log(obj.number) // output: 105
Any valid javascript value.
Object on which to create the reactive property.
Key for the new property.
Observable instance that stores the value of the reactive property.
Extracts the Observable instance from a property on an object.
This function will only work if the defineReactiveProperty method was used to define that property.
Object where you have a reactive property.
Key of the property that has an observable instance.
Takes a data object and recursively makes all its properties reactive.
Function definitions within the data object are treated as computed property definitions.
const observed = observe({
price: 55,
quantity: 10,
total() {
return this.price * this.quantity;
}
});
console.log(observed); // output: { price: 55, quantity: 10, total: 550 }
Plain javascript object.
Object to process.
Iterate over a data object and make all its properties reactive.
Any object type: array, object, class etc.
Data object.
Optional observable for the data object.
Generated using TypeDoc
Module with functions that emulate vue's 2.x reactivity mechanism.