8000 revert "feat(observable): enhance event callback type specificity" (#… · NativeScript/NativeScript@922f6ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 922f6ce

Browse files
authored
revert "feat(observable): enhance event callback type specificity" (#10721)
Revert "feat(observable): enhance event callback type specificity (#10720)" This reverts commit e2f9687.
1 parent cfc27eb commit 922f6ce

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

packages/core/data/observable/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Optional, EndsWith } from '../../utils/typescript-utils';
1+
import { Optional } from '../../utils/typescript-utils';
22

33
/**
44
* Base event data.
@@ -160,7 +160,7 @@ export class Observable {
160160
* `this` context when the callback is called. Falsy values will be not be
161161
* bound.
162162
*/
163-
public on<S extends string>(eventName: S, callback: (data: EndsWith<S, 'Change', PropertyChangeData, EventData>) => void, thisArg?: any): void {
163+
public on(eventName: string, callback: (data: EventData) => void, thisArg?: any): void {
164164
this.addEventListener(eventName, callback, thisArg);
165165
}
166166

@@ -175,7 +175,7 @@ export class Observable {
175175
* `this` context when the callback is called. Falsy values will be not be
176176
* bound.
177177
*/
178-
public once<S extends string>(eventName: S, callback: (data: EndsWith<S, 'Change', PropertyChangeData, EventData>) => void, thisArg?: any): void {
178+
public once(eventName: string, callback: (data: EventData) => void, thisArg?: any): void {
179179
this.addEventListener(eventName, callback, thisArg, true);
180180
}
181181

@@ -188,7 +188,7 @@ export class Observable {
188188
* @param thisArg An optional parameter which, when set, will be used to
189189
* refine search of the correct event listener to be removed.
190190
*/
191-
public off<S extends string>(eventName: S, callback?: (data: EndsWith<S, 'Change', PropertyChangeData, EventData>) => void, thisArg?: any): void {
191+
public off(eventName: string, callback?: (data: EventData) => void, thisArg?: any): void {
192192
this.removeEventListener(eventName, callback, thisArg);
193193
}
194194

packages/core/utils/typescript-utils.d.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,3 @@
44
* // returns: { eventName: string; object?: Observable }
55
*/
66
export type Optional<T, K extends keyof T> = Omit<T, K> & { [P in K]?: T[P] };
7-
8-
/**
9-
* Determines if a string type ends with a specified suffix.
10-
* @example type IsChangeEvent = EndsWith<"propertyNameChange", "Change", true, false>
11-
* // returns: true
12-
* @example type IsChangeEvent = EndsWith<"someEvent", "Change", true, false>
13-
* // returns: false
14-
*/
15-
export type EndsWith<T extends string, S extends string, PassType = true, FailType = false> = T extends `${infer _}${S}` ? PassType : FailType;

0 commit comments

Comments
 (0)
0