https://www.npmjs.com/package/lodash-decorators

lodash-decorators

  1. npm install --save lodash lodash-decorators
  2. import { Debounce } from 'lodash-decorators';
  3. import Debounce from 'lodash-decorators/debounce';
  1. import { Debounce, Memoize } from 'lodash-decorators';
  2. class Person {
  3. constructor(firstName, lastName) {
  4. this.firstName = firstName;
  5. this.lastName = lastName;
  6. }
  7. @Debounce(100)
  8. save(date) {
  9. return this.httpService.post(data);
  10. }
  11. @Memoize(item => item.id)
  12. doSomeHeavyProcessing(arg1, arg2) {}
  13. }
  14. class Person {
  15. @Memoize()
  16. doSomething() {}
  17. @Memoize
  18. doSomething2() {}
  19. @memoize()
  20. doSomething3() {}
  21. @memoize
  22. doSomething4() {}
  23. }