8000 fix(core): missing parameter for once event listeners (#10715) · CatchABus/NativeScript@852011c · GitHub
[go: up one dir, main page]

Skip to content

Commit 852011c

Browse files
authored
fix(core): missing parameter for once event listeners (NativeScript#10715)
1 parent 50019ec commit 852011c

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

packages/core/data/observable/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export class Observable {
197197
* @param eventName Name of the event to attach to.
198198
* @param callback A function to be called when some of the specified event(s) is raised.
199199
* @param thisArg An optional parameter which when set will be used as "this" in callback method call.
200+
* @param once An optional parameter which when set will cause the event listener to fire once.
200201
*/
201202
public addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): void {
202203
once = once || undefined;

packages/core/media-query-list/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class MediaQueryListImpl extends Observable implements MediaQueryList {
118118
}
119119

120120
// @ts-ignore
121-
public addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any): void {
121+
public addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): void {
122122
this._throwInvocationError?.();
123123

124124
const hasChangeListeners = this.hasListeners(MediaQueryListImpl.changeEvent);
125125

126126
// Call super method first since it throws in the case of bad parameters
127-
super.addEventListener(eventName, callback, thisArg);
127+
super.addEventListener(eventName, callback, thisArg, once);
128128

129129
if (eventName === MediaQueryListImpl.changeEvent && !hasChangeListeners) {
130130
mediaQueryLists.push(this);

packages/core/ui/core/view/index.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ export class View extends ViewCommon {
335335
}
336336
}
337337

338-
addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any) {
339-
super.addEventListener(eventNames, callback, thisArg);
338+
addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean) {
339+
super.addEventListener(eventNames, callback, thisArg, once);
340340
const isLayoutEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false;
341341

342342
if (this.isLoaded && !this.layoutChangeListenerIsSet && isLayoutEvent) {

packages/core/ui/core/view/view-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
303303
return this._gestureObservers[type];
304304
}
305305

306-
public addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any) {
306+
public addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean) {
307307
thisArg = thisArg || undefined;
308308

309309
// TODO: Remove this once we fully switch to the new event system
@@ -330,7 +330,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
330330
return;
331331
}
332332

333-
super.addEventListener(normalizedName, callback, thisArg);
333+
super.addEventListener(normalizedName, callback, thisArg, once);
334334
}
335335

336336
public removeEventListener(eventNames: string, callback?: (data: EventData) => void, thisArg?: any) {

packages/core/ui/scroll-view/scroll-view-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe
1717

1818
private _addedScrollEvent = false;
1919

20-
public addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any): void {
20+
public addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): void {
2121
const hasExistingScrollListeners: boolean = this.hasListeners(ScrollViewBase.scrollEvent);
2222

23-
super.addEventListener(arg, callback, thisArg);
23+
super.addEventListener(arg, callback, thisArg, once);
2424

2525
// This indicates that a scroll listener was added for first time
2626
if (!hasExistingScrollListeners && this.hasListeners(ScrollViewBase.scrollEvent)) {

packages/core/ui/text-base/span.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export class Span extends ViewBase implements SpanDefinition {
113113
return this._tappable;
114114
}
115115

116-
addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any): void {
117-
super.addEventListener(arg, callback, thisArg);
116+
addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): void {
117+
super.addEventListener(arg, callback, thisArg, once);
118118
this._setTappable(this.hasListeners(Span.linkTapEvent));
119119
}
120120

0 commit comments

Comments
 (0)
0