esl
esl copied to clipboard
[🚀esl-event-listener]: introduce a simple way to resubscribe listeners
As an ESL user, I may want to resubscribe a group of subscription in the most efficient way.
At the current state of things:
// Resubscribe consist of direct unsubscribe
this.$$off(this._onEvent1);
this.$$off(this._onEvent2);
this.$$on(this._onEvent1);
this.$$on(this._onEvent2);
It is requested to provide the following API:
this.$$reset(this._onEvent1);
this.$$reset(this._onEvent2);
it is requested to have the following ways as well:
this.$$reset('click');
// https://github.com/exadel-inc/esl/issues/2381
this.$$reset({group: 'group'});
// That one is definitely nice to have (we don't have this out of the box technically)
this.$$reset([this._onEvent1, this._onEvent2]);
Open questions:
- The name for Element API (Mixin and BaseElement):
this.$$reset
- The name for low-level API:
ESLEventUtils.resubscribe(...)
Open technical questions:
- Can we make this resubscriptions efficiently (only if required)?
--- Discussion Notes ----
- Positive vote:
this.$$reset(this._onEvent1);
this.$$reset('click');
// https://github.com/exadel-inc/esl/issues/2381
this.$$reset({group: 'group'});
- Rather negative vote (for now):
this.$$on({group: '..'});
this.$$on('click');
- Only if technically simple
this.$$reset([this._onEvent1, this._onEvent2]);
- Alt Naming
-
this.$$reinit
+ ( 3 2 3 2 1 1.5 3 ) -
this.$$reset
( 0 1 0 1 2 1.5 0 )
-