- Introduction
- Introduction to Mobservable
- The Basics: Making stuff Reactive
- Core API
- Advanced API
- Best Practices For Large Apps
- 5.1. Definging data stores
- 5.2. Writing (async) actions
- 5.3. Organizing React components
- 5.4. Universal applications —>
- How does Mobservable work?
- Tips & Tricks
- 7.1. DevTools
- 7.2. ES6 & TypeScript goodies
- 7.3. Tracking state changes
- 7.4. Predicates
- 7.5. Performance considerations
- 8. Resources
- 9. Frequently Asked Questions
- Published with GitBook
Introduction
extendReactive
Quite similar to Object.assign
, extendReactive
takes two arguments, a target
object and a properties
map, and addes all key-value pairs from the properties to the target
as reactive properties. This is very useful in constructor functions or to extend already reactive objects.
var Person = function(firstName, lastName) {
// initialize reactive properties on a new instance
extendReactive(this, {
firstName: firstName,
lastName: lastName
});
}
var matthew = new Person("Matthew", "Henry");
// add a reactive property to an already reactive object
extendReactive(matthew, {
age: 353
});
Note that makeReactive(object)
is actually an alias for extendReactive(object, object)
.