discourse/app/assets/javascripts/discourse-common/addon
David Taylor e08a0b509d
DEV: Support @debounce decorator in native class syntax (#20521)
The implementation previously generated a descriptor with an `initializer()`, and bound the function to the `this` context of the initializer. In native class syntax, the initializer of a descriptor is only called once, with a `this` context of the constructor, not the instance.

This commit updates the implementation so that it generates the bound function on-demand using a getter. This is the same strategy employed by ember's built-in `@action` decorator.

Unfortunately, this use of a getter means that the `@observes` decorator does not support being directly chained to `@debounce`. It throws the error "`observer must be provided a function or an observer definition`". The workaround is to put the observer on its own function, which then calls the debounced function. Given that we're aiming to reduce our usage of `@observes`, we've accepted the need for this workaround rather than spending the time to patch the implementation of `@observes`.
2023-03-03 11:48:58 +00:00
..
config DEV: Add unique ids to deprecations (#19019) 2022-11-16 10:00:39 +00:00
helpers DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
lib FIX: Validate asset url before replacing base url (#16438) 2023-01-30 07:32:48 +08:00
utils DEV: Support @debounce decorator in native class syntax (#20521) 2023-03-03 11:48:58 +00:00
.gitkeep
resolver.js DEV: Remove Ember.TEMPLATES and centralize template resolution rules (#19220) 2022-11-29 10:24:35 +00:00