meteor-decorators

Helper decorators for meteor

this package has been deprecated
Last updated a year ago by ymchun .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install meteor-decorators 
SYNC missed versions from official npm registry.

npm version Known Vulnerabilities codecov Build Status

meteor-decorators

Helper decorators for meteor

Install

$ npm install meteor-decorators

Usage

import { MeteorClass, MeteorPublish, MeteorMethod } from 'meteor-decorators';

@MeteorClass
export class SomeClass {
  /*
  *
  * 'dataList' will be published as 'data.list'
  * e.g. 'dataListPublic' will be published as 'data.list.public'
  * any arguments to Meteor.subscribe will be passed directly into this method
  */
  @MeteorPublish()
  public dataList(arg1: string, arg2: string): ObservableCursor<T> {
    return Collection.find(
      // do query
    );
  }

  /*
  *
  * 'someMeteorMethod' can be called by Meteor.call with the same name
  * any arguments to Meteor.call will be passed directly into this method
  */
  @MeteorMethod()
  public someMeteorMethod(arg1: string, arg2: string): void {
    // do something
  }
}

Publication & method scope

The class decorator will add Meteor publication & method scope properties to decorated class directly. You can access those properties & method from this.scope.

Type Issue

Currently there is no way to mutate class by decorators. In order to suppress type warnings, the following is one of possible workaround.

// when calling unblock of meteor method
// cast 'this' to any type
(this as any).scope.unblock();

Related issue: https://github.com/Microsoft/TypeScript/issues/4881

Current Tags

  • 1.0.16                                ...           latest (a year ago)

16 Versions

  • 1.0.16 [deprecated]           ...           a year ago
  • 1.0.15 [deprecated]           ...           a year ago
  • 1.0.14 [deprecated]           ...           a year ago
  • 1.0.12 [deprecated]           ...           a year ago
  • 1.0.11 [deprecated]           ...           a year ago
  • 1.0.10 [deprecated]           ...           a year ago
  • 1.0.9 [deprecated]           ...           a year ago
  • 1.0.8 [deprecated]           ...           a year ago
  • 1.0.7 [deprecated]           ...           a year ago
  • 1.0.6 [deprecated]           ...           a year ago
  • 1.0.5 [deprecated]           ...           a year ago
  • 1.0.4 [deprecated]           ...           a year ago
  • 1.0.3 [deprecated]           ...           a year ago
  • 1.0.2 [deprecated]           ...           a year ago
  • 1.0.1 [deprecated]           ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (1)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |