Refactor onUseUnuse function in SE instance
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
The following discussion from !76489 (merged) should be addressed:
-
@himkp started a discussion: (+2 comments) Suggestion: It seems that we have a little more abstraction than necessary, just to support a singular extension definition and an array of extension definitions. Ideally, I'd like to see us using restparams, so that works for both singular and multiple extensions.
Anyways, this function can be simplified to:
static useUnuse(extensionsStore, fn, extensions) { return extensions.length ? extensions.map(fn.bind(this, extensionsStore)) : fn.call(this, extensionsStore, extensions); }
If we agree to use restparams for
extensions
, this can be further simplified to:static useUnuse(extensionsStore, fn, ext0, ...extN) { return [ext0, ...extN].map(fn.bind(this, extensionsStore)); }
At which point, I would recommend removing this function and using the one liner in both
useExtension
andunuseExtension
functions. We can also combineuse
anduseExtension
(andunuse
andunuseExtension
) functions into one.