Introduction

Edit This Page

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.

  1. var Person = function(firstName, lastName) {
  2. // initialize reactive properties on a new instance
  3. extendReactive(this, {
  4. firstName: firstName,
  5. lastName: lastName
  6. });
  7. }
  8. var matthew = new Person("Matthew", "Henry");
  9. // add a reactive property to an already reactive object
  10. extendReactive(matthew, {
  11. age: 353
  12. });

Note that makeReactive(object) is actually an alias for extendReactive(object, object).