You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/automated/src/data/observable-tests.ts
+12-8Lines changed: 12 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,7 @@ export var test_Observable_addEventListener_MultipleEvents = function () {
163
163
obj.addEventListener(events,callback);
164
164
obj.set('testName',1);
165
165
obj.test();
166
-
TKUnit.assert(receivedCount===2,'Callbacks not raised properly.');
166
+
TKUnit.assert(receivedCount===0,"Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange,tested', as we have dropped support for listening to plural event names.");
TKUnit.assert(obj.hasListeners(Observable.propertyChangeEvent),'Observable.addEventListener for multiple events should trim each event name.');
180
-
TKUnit.assert(obj.hasListeners(TESTED_NAME),'Observable.addEventListener for multiple events should trim each event name.');
179
+
TKUnit.assert(obj.hasListeners(events),"Expected a listener to be present for event name 'propertyChange , tested', as we have dropped support for splitting plural event names.");
180
+
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent),"Expected no listeners to be present for event name 'propertyChange', as we have dropped support for splitting plural event names.");
181
+
TKUnit.assert(!obj.hasListeners(TESTED_NAME),"Expected no listeners to be present for event name 'tested', as we have dropped support for splitting plural event names.");
181
182
182
183
obj.set('testName',1);
183
184
obj.test();
184
185
185
-
TKUnit.assert(receivedCount===2,'Callbacks not raised properly.');
186
+
TKUnit.assert(receivedCount===0,"Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
@@ -223,7 +224,7 @@ export var test_Observable_addEventListener_MultipleCallbacks_MultipleEvents = f
223
224
obj.set('testName',1);
224
225
obj.test();
225
226
226
-
TKUnit.assert(receivedCount===4,'The propertyChanged notification should be raised twice.');
227
+
TKUnit.assert(receivedCount===0,"Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested' with two different callbacks, as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
TKUnit.assert(obj.hasListeners(events),"Expected a listener to be present for event name 'propertyChange , tested', as we have dropped support for splitting plural event names.");
346
+
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent),"Expected no listeners to be present for event name 'propertyChange', as we have dropped support for splitting plural event names.");
347
+
TKUnit.assert(!obj.hasListeners(TESTED_NAME),"Expected no listeners to be present for event name 'tested', as we have dropped support for splitting plural event names.");
348
+
TKUnit.assert(receivedCount===0,"Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
344
349
345
350
obj.set('testName',1);
346
351
obj.test();
347
352
348
353
obj.removeEventListener(events,callback);
349
354
350
-
TKUnit.assert(!obj.hasListeners(Observable.propertyChangeEvent),'Expected result for hasObservers is false');
351
-
TKUnit.assert(!obj.hasListeners(TESTED_NAME),'Expected result for hasObservers is false.');
355
+
TKUnit.assert(!obj.hasListeners(events),"Expected the listener for event name 'propertyChange , tested' to have been removed, as we have dropped support for splitting plural event names.");
352
356
353
357
obj.set('testName',2);
354
358
obj.test();
355
359
356
-
TKUnit.assert(receivedCount===2,'Expected receive count is 2');
360
+
TKUnit.assert(receivedCount===0,"Expected no event handlers to fire upon the 'propertyChange' event when listening for event name 'propertyChange , tested', as we have dropped support for listening to plural event names (and trimming whitespace in event names).");
Copy file name to clipboardExpand all lines: packages/core/data/observable/index.ts
+62-74Lines changed: 62 additions & 74 deletions
Original file line number
Diff line number
Diff line change
@@ -89,8 +89,6 @@ const _globalEventHandlers: {
89
89
};
90
90
}={};
91
91
92
-
consteventNamesRegex=/\s*,\s*/;
93
-
94
92
/**
95
93
* Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener.
96
94
* Please note that should you be using the `new Observable({})` constructor, it is **obsolete** since v3.0,
@@ -153,93 +151,89 @@ export class Observable {
153
151
154
152
/**
155
153
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
156
-
* @parameventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
154
+
* @parameventName Name of the event to attach to.
157
155
* @param callback - Callback function which will be executed when event is raised.
158
156
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
0 commit comments