Skip to content

Reactive objects using ECMAScript 5 Object features, without the need for getters and setters.

License

Notifications You must be signed in to change notification settings

jonjamz/reactive-object

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Now features support for array prototype methods. However, you must use the provided clean() method to get an array without methods:

var obj = new ReactiveObject({'cars':['lamborghini', 'ferrari']});

// Use this property somewhere reactive
Template.cars.helpers({
  carTypes: function () {
    return obj.cars.clean(); // This will remove all array items with function type
  }
});

This is a Meteor smart package containing a class for reactive objects. These reactive objects use ECMAScript 5 Object features to hook reactivity into the normal JS getters and setters. This means that once you establish the initial properties in the object, there's no need to call a setter or an update method on the properties to change them. You can set them as you would any normal JS object property, and Deps will be triggered.

Install

meteor add mrt:reactive-object

Usage

var obj = new ReactiveObject({'foo':'1'});
obj.defineProperty('bar', 2);

obj.foo = '2';
obj.undefineProperty('foo'); // Don't use 'delete obj.foo' it will give strange results

Authors

Warnar Boekkooi, author of the more feature-rich reactive-extra. Forked and edited by me, Jon Jamz. I'm maintaining this as a separate package.

Alternatives

The main difference between this package and reactive-objects is that you need to do some extra work to get reactive-objects going. This one is simpler and just assumes that all the properties in an object are supposed to be reactive.

About

Reactive objects using ECMAScript 5 Object features, without the need for getters and setters.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%