This API is deprecated since version 0.7.1 and will be removed in a future release

MeteorReactive

A basic class to extend @Component and @Pipe. Contains wrappers over main Meteor methods that does some maintenance work behind the scene:

  • Destroys subscription handles when the component or pipe is destroyed by Angular 2.
  • Debounces ngZone runs reducing number of change detection runs.

Kind: global class

meteorReactive.autorun(func, autoBind) ⇒ Tracker.Computation

Method has the same notation as Meteor.autorun except the last parameter.

Kind: instance method of MeteorReactive
Returns: Tracker.Computation - - Object representing the Meteor computation
See

Param Type Default Description
func autorunCallback Callback to be executed when current computation is invalidated. The Tracker.Computation object will be passed as argument to this callback.
autoBind Boolean true Determine whether Angular2 Zone will run after the func call to initiate change detection.

Example

class MyComponent extends MeteorReactive {
   private myData: Mongo.Cursor;
   private dataId: any;

   constructor() {
     super();

     this.autorun(() => {
       this.myData = MyCollection.find({ _id: dataId});
     }, true);
   }
}

meteorReactive.subscribe(name, ...args, autoBind) ⇒ Meteor.SubscriptionHandle

Method has the same notation as Meteor.subscribe: subscribe(name, [args1, args2], [callbacks], [autoBind]) except the last autoBind param (see autorun above).

Kind: instance method of MeteorReactive
Returns: Meteor.SubscriptionHandle - - The handle of the subscription created by Meteor.
See: Publication/Subscription in Meteor documentation

Param Type Description
name String Name of the publication in the Meteor server
...args any Parameters that will be forwarded to the publication.
autoBind Boolean Determine whether Angular 2 zone will run after the func call to initiate change detection.

Example

class MyComponent extends MeteorReactive {
    constructor() {
      super();

      this.subscribe("myData", 10);
    }
 }

meteorReactive.call(name, ...args, autoBind) ⇒ void

Method has the same notation as Meteor.call: call(name, [args1, args2], [callbacks], [autoBind]) except the last autoBind param (see autorun above).

Kind: instance method of MeteorReactive

Param Type Description
name String Name of the publication in the Meteor server
...args any Parameters that will be forwarded to the method.
autoBind Boolean autoBind Determine whether Angular 2 zone will run after the func call to initiate change detection.

Example

class MyComponent extends MeteorReactive {
    constructor() {
      super();

      this.call("serverMethod", (err, result) => {
         // Handle response...
      });
    }
 }

MeteorReactive~autorunCallback : function

This callback called when autorun triggered by Meteor.

Kind: inner typedef of MeteorReactive

Param Type
computation Tracker.Computation