axis-decorators
重新封装的装饰器函数
Last updated 7 months ago by leomyili .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install axis-decorators 
SYNC missed versions from official npm registry.

axis-decorator

重新封装的装饰器函数

????Decorators:

decorateFunc(Methods)

可使用外部辅助计算函数对 class 方法进行包装

import { decorateFunc } from 'axis-decorators';
import { memoize } from 'lodash';

class Task {
  @decorateFunc(memoize)
  doSomethingExpensive(data) {
    count++;
    // something expensive;
    return data;
  }
}

nonenumerable(Property)

将属性标记为不可枚举

import { nonenumerable } from 'axis-decorators';

class Test {
  name = 'test';

  @nonenumerable
  count = 10;
}

override(Methods)

检查标记的方法是否确实覆盖原型链上某处具有相同签名的函数

import { override } from 'axis-decorators';

class Parent {
  speak(first, second) {}
}

class Child extends Parent {
  @override
  speak() {}
  // SyntaxError: Child#speak() does not properly override Parent#speak(first, second)
}

persistence(Property)

持久化属性,用于收集所有需要进行持久化保存的属性,可传参:singlePage or global

import { persistence } from 'axis-decorators';

export default class store extends BaseStore {
  @observable
  step = 100;

  @observable
  @persistence()
  markLineList = [];
}

Current Tags

  • 1.3.0                                ...           latest (7 months ago)

4 Versions

  • 1.3.0                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.0                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 13
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |