jayphelps / core-decorators

Library of stage-0 JavaScript decorators (aka ES2016/ES7 decorators but not accurate) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic.
MIT License
4.52k stars 263 forks source link

@debouce - deprecation discussion #125

Closed allangomes closed 7 years ago

allangomes commented 7 years ago

I'm know that @debounce already exists on lodash, but I don't want to use it for the following reasons:

why don't you re-export from lodash?

thanks in advance

jayphelps commented 7 years ago

If you use lodash-decorators you can import individual decorators, without importing everything, like this:

import debounce from 'lodash-decorators/debounce';

class Foo {
  @debounce(200)
  test() {
    // stuff
  }
}

Or if you want to use just core-decorator's @decorate with the raw lodash debounce function, you can probably do that too, but I can't haven't tested it so there may be issues dealing with prototype inheritance (e.g. incorrectly sharing timers between instances)

import debounce from 'lodash/debounce';
import decorate from 'core-decorators/lib/decorate';

class Foo {
  @decorate(debounce, 200)
  test() {
    // stuff
  }
}

I don't want to duplicate the effort of lodash-decorators, which indeed is basically just decorator wrappers around lodash.

BurtHarris commented 7 years ago

What's the schedule on removing these deprecated features? Some of the tests failing when I try to use TypeScript with core-decorators are around deprecated features.

jayphelps commented 7 years ago

@BurtHarris there's no real schedule. Whenever.

Closing this ticket as there hasn't been a response and I think I answered their question. Lmk if not.

allangomes commented 7 years ago

If lodash/decorators already have all anotations, why should I continue to use core/decorators?

jayphelps commented 7 years ago

@allangomessl that doesn't sound like a question.

giannif commented 7 years ago

@jayphelps I get your intention, but this is kind of a bummer since it adds some bulk even when using:

import debounce from 'lodash-decorators/debounce';

Webpack Bundle Analyzer:

I also have to change all my import statements, and there are many. I guess you've made up your mind, but I 100% agree with the reasons listed by @allangomessl