Best JavaScript code snippet using storybook-root
CCEventManager.js
Source:CCEventManager.js
1/****************************************************************************2 Copyright (c) 2011-2012 cocos2d-x.org3 Copyright (c) 2013-2014 Chukong Technologies Inc.4 http://www.cocos2d-x.org5 Permission is hereby granted, free of charge, to any person obtaining a copy6 of this software and associated documentation files (the "Software"), to deal7 in the Software without restriction, including without limitation the rights8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell9 copies of the Software, and to permit persons to whom the Software is10 furnished to do so, subject to the following conditions:11 The above copyright notice and this permission notice shall be included in12 all copies or substantial portions of the Software.13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN19 THE SOFTWARE.20 ****************************************************************************/21/**22 * @ignore23 */24cc._EventListenerVector = cc.Class.extend({25 _fixedListeners: null,26 _sceneGraphListeners: null,27 gt0Index: 0,28 ctor: function () {29 this._fixedListeners = [];30 this._sceneGraphListeners = [];31 },32 size: function () {33 return this._fixedListeners.length + this._sceneGraphListeners.length;34 },35 empty: function () {36 return (this._fixedListeners.length === 0) && (this._sceneGraphListeners.length === 0);37 },38 push: function (listener) {39 if (listener._getFixedPriority() == 0)40 this._sceneGraphListeners.push(listener);41 else42 this._fixedListeners.push(listener);43 },44 clearSceneGraphListeners: function () {45 this._sceneGraphListeners.length = 0;46 },47 clearFixedListeners: function () {48 this._fixedListeners.length = 0;49 },50 clear: function () {51 this._sceneGraphListeners.length = 0;52 this._fixedListeners.length = 0;53 },54 getFixedPriorityListeners: function () {55 return this._fixedListeners;56 },57 getSceneGraphPriorityListeners: function () {58 return this._sceneGraphListeners;59 }60});61cc.__getListenerID = function (event) {62 var eventType = cc.Event, getType = event.getType();63 if(getType === eventType.ACCELERATION)64 return cc._EventListenerAcceleration.LISTENER_ID;65 if(getType === eventType.CUSTOM)66 return event.getEventName();67 if(getType === eventType.KEYBOARD)68 return cc._EventListenerKeyboard.LISTENER_ID;69 if(getType === eventType.MOUSE)70 return cc._EventListenerMouse.LISTENER_ID;71 if(getType === eventType.TOUCH){72 // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce.73 // return UNKNOWN instead.74 cc.log(cc._LogInfos.__getListenerID);75 }76 return "";77};78/**79 * <p>80 * cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. <br/>81 * <br/>82 * The EventListener list is managed in such way so that event listeners can be added and removed <br/>83 * while events are being dispatched.84 * </p>85 * @class86 * @name cc.eventManager87 */88cc.eventManager = /** @lends cc.eventManager# */{89 //Priority dirty flag90 DIRTY_NONE:0,91 DIRTY_FIXED_PRIORITY:1 <<0,92 DIRTY_SCENE_GRAPH_PRIORITY : 1<< 1,93 DIRTY_ALL: 3,94 _listenersMap: {},95 _priorityDirtyFlagMap: {},96 _nodeListenersMap: {},97 _nodePriorityMap: {},98 _globalZOrderNodeMap: {},99 _toAddedListeners: [],100 _dirtyNodes: [],101 _inDispatch: 0,102 _isEnabled: false,103 _nodePriorityIndex: 0,104 _internalCustomListenerIDs:[cc.game.EVENT_HIDE, cc.game.EVENT_SHOW],105 _setDirtyForNode: function (node) {106 // Mark the node dirty only when there is an event listener associated with it.107 if (this._nodeListenersMap[node.__instanceId] != null)108 this._dirtyNodes.push(node);109 var _children = node.getChildren();110 for(var i = 0, len = _children.length; i < len; i++)111 this._setDirtyForNode(_children[i]);112 },113 /**114 * Pauses all listeners which are associated the specified target.115 * @param {cc.Node} node116 * @param {Boolean} [recursive=false]117 */118 pauseTarget: function (node, recursive) {119 var listeners = this._nodeListenersMap[node.__instanceId], i, len;120 if (listeners) {121 for ( i = 0, len = listeners.length; i < len; i++)122 listeners[i]._setPaused(true);123 }124 if (recursive === true) {125 var locChildren = node.getChildren();126 for ( i = 0, len = locChildren.length; i< len; i++)127 this.pauseTarget(locChildren[i], true);128 }129 },130 /**131 * Resumes all listeners which are associated the specified target.132 * @param {cc.Node} node133 * @param {Boolean} [recursive=false]134 */135 resumeTarget: function (node, recursive) {136 var listeners = this._nodeListenersMap[node.__instanceId], i, len;137 if (listeners){138 for ( i = 0, len = listeners.length; i < len; i++)139 listeners[i]._setPaused(false);140 }141 this._setDirtyForNode(node);142 if (recursive === true) {143 var locChildren = node.getChildren();144 for ( i = 0, len = locChildren.length; i< len; i++)145 this.resumeTarget(locChildren[i], true);146 }147 },148 _addListener: function (listener) {149 if (this._inDispatch === 0)150 this._forceAddEventListener(listener);151 else152 this._toAddedListeners.push(listener);153 },154 _forceAddEventListener: function (listener) {155 var listenerID = listener._getListenerID();156 var listeners = this._listenersMap[listenerID];157 if (!listeners) {158 listeners = new cc._EventListenerVector();159 this._listenersMap[listenerID] = listeners;160 }161 listeners.push(listener);162 if (listener._getFixedPriority() == 0) {163 this._setDirty(listenerID, this.DIRTY_SCENE_GRAPH_PRIORITY);164 var node = listener._getSceneGraphPriority();165 if (node == null)166 cc.log(cc._LogInfos.eventManager__forceAddEventListener);167 this._associateNodeAndEventListener(node, listener);168 if (node.isRunning())169 this.resumeTarget(node);170 } else171 this._setDirty(listenerID, this.DIRTY_FIXED_PRIORITY);172 },173 _getListeners: function (listenerID) {174 return this._listenersMap[listenerID];175 },176 _updateDirtyFlagForSceneGraph: function () {177 if (this._dirtyNodes.length == 0)178 return;179 var locDirtyNodes = this._dirtyNodes, selListeners, selListener, locNodeListenersMap = this._nodeListenersMap;180 for (var i = 0, len = locDirtyNodes.length; i < len; i++) {181 selListeners = locNodeListenersMap[locDirtyNodes[i].__instanceId];182 if (selListeners) {183 for (var j = 0, listenersLen = selListeners.length; j < listenersLen; j++) {184 selListener = selListeners[j];185 if (selListener)186 this._setDirty(selListener._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);187 }188 }189 }190 this._dirtyNodes.length = 0;191 },192 _removeAllListenersInVector: function (listenerVector) {193 if (!listenerVector)194 return;195 var selListener;196 for (var i = 0; i < listenerVector.length;) {197 selListener = listenerVector[i];198 selListener._setRegistered(false);199 if (selListener._getSceneGraphPriority() != null){200 this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener);201 selListener._setSceneGraphPriority(null); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.202 }203 if (this._inDispatch === 0)204 cc.arrayRemoveObject(listenerVector, selListener);205 else206 ++i;207 }208 },209 _removeListenersForListenerID: function (listenerID) {210 var listeners = this._listenersMap[listenerID], i;211 if (listeners) {212 var fixedPriorityListeners = listeners.getFixedPriorityListeners();213 var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners();214 this._removeAllListenersInVector(sceneGraphPriorityListeners);215 this._removeAllListenersInVector(fixedPriorityListeners);216 // Remove the dirty flag according the 'listenerID'.217 // No need to check whether the dispatcher is dispatching event.218 delete this._priorityDirtyFlagMap[listenerID];219 if (!this._inDispatch) {220 listeners.clear();221 delete this._listenersMap[listenerID];222 }223 }224 var locToAddedListeners = this._toAddedListeners, listener;225 for (i = 0; i < locToAddedListeners.length;) {226 listener = locToAddedListeners[i];227 if (listener && listener._getListenerID() == listenerID)228 cc.arrayRemoveObject(locToAddedListeners, listener);229 else230 ++i;231 }232 },233 _sortEventListeners: function (listenerID) {234 var dirtyFlag = this.DIRTY_NONE, locFlagMap = this._priorityDirtyFlagMap;235 if (locFlagMap[listenerID])236 dirtyFlag = locFlagMap[listenerID];237 if (dirtyFlag != this.DIRTY_NONE) {238 // Clear the dirty flag first, if `rootNode` is null, then set its dirty flag of scene graph priority239 locFlagMap[listenerID] = this.DIRTY_NONE;240 if (dirtyFlag & this.DIRTY_FIXED_PRIORITY)241 this._sortListenersOfFixedPriority(listenerID);242 if (dirtyFlag & this.DIRTY_SCENE_GRAPH_PRIORITY){243 var rootNode = cc.director.getRunningScene();244 if(rootNode)245 this._sortListenersOfSceneGraphPriority(listenerID, rootNode);246 else247 locFlagMap[listenerID] = this.DIRTY_SCENE_GRAPH_PRIORITY;248 }249 }250 },251 _sortListenersOfSceneGraphPriority: function (listenerID, rootNode) {252 var listeners = this._getListeners(listenerID);253 if (!listeners)254 return;255 var sceneGraphListener = listeners.getSceneGraphPriorityListeners();256 if(!sceneGraphListener || sceneGraphListener.length === 0)257 return;258 // Reset priority index259 this._nodePriorityIndex = 0;260 this._nodePriorityMap = {};261 this._visitTarget(rootNode, true);262 // After sort: priority < 0, > 0263 listeners.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes);264 },265 _sortEventListenersOfSceneGraphPriorityDes : function(l1, l2){266 var locNodePriorityMap = cc.eventManager._nodePriorityMap;267 if(!l1 || !l2 || !l1._getSceneGraphPriority() || !l2._getSceneGraphPriority())268 return -1;269 return locNodePriorityMap[l2._getSceneGraphPriority().__instanceId] - locNodePriorityMap[l1._getSceneGraphPriority().__instanceId];270 },271 _sortListenersOfFixedPriority: function (listenerID) {272 var listeners = this._listenersMap[listenerID];273 if (!listeners)274 return;275 var fixedListeners = listeners.getFixedPriorityListeners();276 if(!fixedListeners || fixedListeners.length === 0)277 return;278 // After sort: priority < 0, > 0279 fixedListeners.sort(this._sortListenersOfFixedPriorityAsc);280 // FIXME: Should use binary search281 var index = 0;282 for (var len = fixedListeners.length; index < len;) {283 if (fixedListeners[index]._getFixedPriority() >= 0)284 break;285 ++index;286 }287 listeners.gt0Index = index;288 },289 _sortListenersOfFixedPriorityAsc: function (l1, l2) {290 return l1._getFixedPriority() - l2._getFixedPriority();291 },292 _onUpdateListeners: function (listenerID) {293 var listeners = this._listenersMap[listenerID];294 if (!listeners)295 return;296 var fixedPriorityListeners = listeners.getFixedPriorityListeners();297 var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners();298 var i, selListener;299 if (sceneGraphPriorityListeners) {300 for (i = 0; i < sceneGraphPriorityListeners.length;) {301 selListener = sceneGraphPriorityListeners[i];302 if (!selListener._isRegistered()) {303 cc.arrayRemoveObject(sceneGraphPriorityListeners, selListener);304 } else305 ++i;306 }307 }308 if (fixedPriorityListeners) {309 for (i = 0; i < fixedPriorityListeners.length;) {310 selListener = fixedPriorityListeners[i];311 if (!selListener._isRegistered())312 cc.arrayRemoveObject(fixedPriorityListeners, selListener);313 else314 ++i;315 }316 }317 if (sceneGraphPriorityListeners && sceneGraphPriorityListeners.length === 0)318 listeners.clearSceneGraphListeners();319 if (fixedPriorityListeners && fixedPriorityListeners.length === 0)320 listeners.clearFixedListeners();321 },322 _updateListeners: function (event) {323 var locInDispatch = this._inDispatch;324 cc.assert(locInDispatch > 0, cc._LogInfos.EventManager__updateListeners);325 if (event.getType() == cc.Event.TOUCH) {326 this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);327 this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);328 } else329 this._onUpdateListeners(cc.__getListenerID(event));330 if(locInDispatch > 1)331 return;332 cc.assert(locInDispatch == 1, cc._LogInfos.EventManager__updateListeners_2);333 var locListenersMap = this._listenersMap, locPriorityDirtyFlagMap = this._priorityDirtyFlagMap;334 for (var selKey in locListenersMap) {335 if (locListenersMap[selKey].empty()) {336 delete locPriorityDirtyFlagMap[selKey];337 delete locListenersMap[selKey];338 }339 }340 var locToAddedListeners = this._toAddedListeners;341 if (locToAddedListeners.length !== 0) {342 for (var i = 0, len = locToAddedListeners.length; i < len; i++)343 this._forceAddEventListener(locToAddedListeners[i]);344 this._toAddedListeners.length = 0;345 }346 },347 _onTouchEventCallback: function(listener, argsObj){348 // Skip if the listener was removed.349 if (!listener._isRegistered)350 return false;351 var event = argsObj.event, selTouch = argsObj.selTouch;352 event._setCurrentTarget(listener._node);353 var isClaimed = false, removedIdx;354 var getCode = event.getEventCode(), eventCode = cc.EventTouch.EventCode;355 if (getCode == eventCode.BEGAN) {356 if (listener.onTouchBegan) {357 isClaimed = listener.onTouchBegan(selTouch, event);358 if (isClaimed && listener._registered)359 listener._claimedTouches.push(selTouch);360 }361 } else if (listener._claimedTouches.length > 0362 && ((removedIdx = listener._claimedTouches.indexOf(selTouch)) != -1)) {363 isClaimed = true;364 if(getCode === eventCode.MOVED && listener.onTouchMoved){365 listener.onTouchMoved(selTouch, event);366 } else if(getCode === eventCode.ENDED){367 if (listener.onTouchEnded)368 listener.onTouchEnded(selTouch, event);369 if (listener._registered)370 listener._claimedTouches.splice(removedIdx, 1);371 } else if(getCode === eventCode.CANCELLED){372 if (listener.onTouchCancelled)373 listener.onTouchCancelled(selTouch, event);374 if (listener._registered)375 listener._claimedTouches.splice(removedIdx, 1);376 }377 }378 // If the event was stopped, return directly.379 if (event.isStopped()) {380 cc.eventManager._updateListeners(event);381 return true;382 }383 if (isClaimed && listener._registered && listener.swallowTouches) {384 if (argsObj.needsMutableSet)385 argsObj.touches.splice(selTouch, 1);386 return true;387 }388 return false;389 },390 _dispatchTouchEvent: function (event) {391 this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);392 this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);393 var oneByOneListeners = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);394 var allAtOnceListeners = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);395 // If there aren't any touch listeners, return directly.396 if (null == oneByOneListeners && null == allAtOnceListeners)397 return;398 var originalTouches = event.getTouches(), mutableTouches = cc.copyArray(originalTouches);399 var oneByOneArgsObj = {event: event, needsMutableSet: (oneByOneListeners && allAtOnceListeners), touches: mutableTouches, selTouch: null};400 //401 // process the target handlers 1st402 //403 if (oneByOneListeners) {404 for (var i = 0; i < originalTouches.length; i++) {405 oneByOneArgsObj.selTouch = originalTouches[i];406 this._dispatchEventToListeners(oneByOneListeners, this._onTouchEventCallback, oneByOneArgsObj);407 if (event.isStopped())408 return;409 }410 }411 //412 // process standard handlers 2nd413 //414 if (allAtOnceListeners && mutableTouches.length > 0) {415 this._dispatchEventToListeners(allAtOnceListeners, this._onTouchesEventCallback, {event: event, touches: mutableTouches});416 if (event.isStopped())417 return;418 }419 this._updateListeners(event);420 },421 _onTouchesEventCallback: function (listener, callbackParams) {422 // Skip if the listener was removed.423 if (!listener._registered)424 return false;425 var eventCode = cc.EventTouch.EventCode, event = callbackParams.event, touches = callbackParams.touches, getCode = event.getEventCode();426 event._setCurrentTarget(listener._node);427 if(getCode == eventCode.BEGAN && listener.onTouchesBegan)428 listener.onTouchesBegan(touches, event);429 else if(getCode == eventCode.MOVED && listener.onTouchesMoved)430 listener.onTouchesMoved(touches, event);431 else if(getCode == eventCode.ENDED && listener.onTouchesEnded)432 listener.onTouchesEnded(touches, event);433 else if(getCode == eventCode.CANCELLED && listener.onTouchesCancelled)434 listener.onTouchesCancelled(touches, event);435 // If the event was stopped, return directly.436 if (event.isStopped()) {437 cc.eventManager._updateListeners(event);438 return true;439 }440 return false;441 },442 _associateNodeAndEventListener: function (node, listener) {443 var listeners = this._nodeListenersMap[node.__instanceId];444 if (!listeners) {445 listeners = [];446 this._nodeListenersMap[node.__instanceId] = listeners;447 }448 listeners.push(listener);449 },450 _dissociateNodeAndEventListener: function (node, listener) {451 var listeners = this._nodeListenersMap[node.__instanceId];452 if (listeners) {453 cc.arrayRemoveObject(listeners, listener);454 if (listeners.length === 0)455 delete this._nodeListenersMap[node.__instanceId];456 }457 },458 _dispatchEventToListeners: function (listeners, onEvent, eventOrArgs) {459 var shouldStopPropagation = false;460 var fixedPriorityListeners = listeners.getFixedPriorityListeners();461 var sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners();462 var i = 0, j, selListener;463 if (fixedPriorityListeners) { // priority < 0464 if (fixedPriorityListeners.length !== 0) {465 for (; i < listeners.gt0Index; ++i) {466 selListener = fixedPriorityListeners[i];467 if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) {468 shouldStopPropagation = true;469 break;470 }471 }472 }473 }474 if (sceneGraphPriorityListeners && !shouldStopPropagation) { // priority == 0, scene graph priority475 for (j = 0; j < sceneGraphPriorityListeners.length; j++) {476 selListener = sceneGraphPriorityListeners[j];477 if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) {478 shouldStopPropagation = true;479 break;480 }481 }482 }483 if (fixedPriorityListeners && !shouldStopPropagation) { // priority > 0484 for (; i < fixedPriorityListeners.length; ++i) {485 selListener = fixedPriorityListeners[i];486 if (selListener.isEnabled() && !selListener._isPaused() && selListener._isRegistered() && onEvent(selListener, eventOrArgs)) {487 shouldStopPropagation = true;488 break;489 }490 }491 }492 },493 _setDirty: function (listenerID, flag) {494 var locDirtyFlagMap = this._priorityDirtyFlagMap;495 if (locDirtyFlagMap[listenerID] == null)496 locDirtyFlagMap[listenerID] = flag;497 else498 locDirtyFlagMap[listenerID] = flag | locDirtyFlagMap[listenerID];499 },500 _visitTarget: function (node, isRootNode) {501 var children = node.getChildren(), i = 0;502 var childrenCount = children.length, locGlobalZOrderNodeMap = this._globalZOrderNodeMap, locNodeListenersMap = this._nodeListenersMap;503 if (childrenCount > 0) {504 var child;505 // visit children zOrder < 0506 for (; i < childrenCount; i++) {507 child = children[i];508 if (child && child.getLocalZOrder() < 0)509 this._visitTarget(child, false);510 else511 break;512 }513 if (locNodeListenersMap[node.__instanceId] != null) {514 if (!locGlobalZOrderNodeMap[node.getGlobalZOrder()])515 locGlobalZOrderNodeMap[node.getGlobalZOrder()] = [];516 locGlobalZOrderNodeMap[node.getGlobalZOrder()].push(node.__instanceId);517 }518 for (; i < childrenCount; i++) {519 child = children[i];520 if (child)521 this._visitTarget(child, false);522 }523 } else {524 if (locNodeListenersMap[node.__instanceId] != null) {525 if (!locGlobalZOrderNodeMap[node.getGlobalZOrder()])526 locGlobalZOrderNodeMap[node.getGlobalZOrder()] = [];527 locGlobalZOrderNodeMap[node.getGlobalZOrder()].push(node.__instanceId);528 }529 }530 if (isRootNode) {531 var globalZOrders = [];532 for (var selKey in locGlobalZOrderNodeMap)533 globalZOrders.push(selKey);534 globalZOrders.sort(this._sortNumberAsc);535 var zOrdersLen = globalZOrders.length, selZOrders, j, locNodePriorityMap = this._nodePriorityMap;536 for (i = 0; i < zOrdersLen; i++) {537 selZOrders = locGlobalZOrderNodeMap[globalZOrders[i]];538 for (j = 0; j < selZOrders.length; j++)539 locNodePriorityMap[selZOrders[j]] = ++this._nodePriorityIndex;540 }541 this._globalZOrderNodeMap = {};542 }543 },544 _sortNumberAsc : function (a, b) {545 return a - b;546 },547 /**548 * <p>549 * Adds a event listener for a specified event. <br/>550 * if the parameter "nodeOrPriority" is a node, it means to add a event listener for a specified event with the priority of scene graph. <br/>551 * if the parameter "nodeOrPriority" is a Number, it means to add a event listener for a specified event with the fixed priority. <br/>552 * </p>553 * @param {cc.EventListener|Object} listener The listener of a specified event or a object of some event parameters.554 * @param {cc.Node|Number} nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.555 * @note The priority of scene graph will be fixed value 0. So the order of listener item in the vector will be ' <0, scene graph (0 priority), >0'.556 * A lower priority will be called before the ones that have a higher value. 0 priority is forbidden for fixed priority since it's used for scene graph based priority.557 * The listener must be a cc.EventListener object when adding a fixed priority listener, because we can't remove a fixed priority listener without the listener handler,558 * except calls removeAllListeners().559 * @return {cc.EventListener} Return the listener. Needed in order to remove the event from the dispatcher.560 */561 addListener: function (listener, nodeOrPriority) {562 cc.assert(listener && nodeOrPriority, cc._LogInfos.eventManager_addListener_2);563 if(!(listener instanceof cc.EventListener)){564 cc.assert(!cc.isNumber(nodeOrPriority), cc._LogInfos.eventManager_addListener_3);565 listener = cc.EventListener.create(listener);566 } else {567 if(listener._isRegistered()){568 cc.log(cc._LogInfos.eventManager_addListener_4);569 return;570 }571 }572 if (!listener.checkAvailable())573 return;574 if (cc.isNumber(nodeOrPriority)) {575 if (nodeOrPriority == 0) {576 cc.log(cc._LogInfos.eventManager_addListener);577 return;578 }579 listener._setSceneGraphPriority(null);580 listener._setFixedPriority(nodeOrPriority);581 listener._setRegistered(true);582 listener._setPaused(false);583 this._addListener(listener);584 } else {585 listener._setSceneGraphPriority(nodeOrPriority);586 listener._setFixedPriority(0);587 listener._setRegistered(true);588 this._addListener(listener);589 }590 return listener;591 },592 /**593 * Adds a Custom event listener. It will use a fixed priority of 1.594 * @param {string} eventName595 * @param {function} callback596 * @return {cc.EventListener} the generated event. Needed in order to remove the event from the dispatcher597 */598 addCustomListener: function (eventName, callback) {599 var listener = new cc._EventListenerCustom(eventName, callback);600 this.addListener(listener, 1);601 return listener;602 },603 /**604 * Remove a listener605 * @param {cc.EventListener} listener an event listener or a registered node target606 */607 removeListener: function (listener) {608 if (listener == null)609 return;610 var isFound, locListener = this._listenersMap;611 for (var selKey in locListener) {612 var listeners = locListener[selKey];613 var fixedPriorityListeners = listeners.getFixedPriorityListeners(), sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners();614 isFound = this._removeListenerInVector(sceneGraphPriorityListeners, listener);615 if (isFound){616 // fixed #4160: Dirty flag need to be updated after listeners were removed.617 this._setDirty(listener._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);618 }else{619 isFound = this._removeListenerInVector(fixedPriorityListeners, listener);620 if (isFound)621 this._setDirty(listener._getListenerID(), this.DIRTY_FIXED_PRIORITY);622 }623 if (listeners.empty()) {624 delete this._priorityDirtyFlagMap[listener._getListenerID()];625 delete locListener[selKey];626 }627 if (isFound)628 break;629 }630 if (!isFound) {631 var locToAddedListeners = this._toAddedListeners;632 for (var i = 0, len = locToAddedListeners.length; i < len; i++) {633 var selListener = locToAddedListeners[i];634 if (selListener == listener) {635 cc.arrayRemoveObject(locToAddedListeners, selListener);636 selListener._setRegistered(false);637 break;638 }639 }640 }641 },642 _removeListenerInVector : function(listeners, listener){643 if (listeners == null)644 return false;645 for (var i = 0, len = listeners.length; i < len; i++) {646 var selListener = listeners[i];647 if (selListener == listener) {648 selListener._setRegistered(false);649 if (selListener._getSceneGraphPriority() != null){650 this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener);651 selListener._setSceneGraphPriority(null); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.652 }653 if (this._inDispatch == 0)654 cc.arrayRemoveObject(listeners, selListener);655 return true;656 }657 }658 return false;659 },660 /**661 * Removes all listeners with the same event listener type or removes all listeners of a node662 * @param {Number|cc.Node} listenerType listenerType or a node663 * @param {Boolean} [recursive=false]664 */665 removeListeners: function (listenerType, recursive) {666 var _t = this;667 if (listenerType instanceof cc.Node) {668 // Ensure the node is removed from these immediately also.669 // Don't want any dangling pointers or the possibility of dealing with deleted objects..670 delete _t._nodePriorityMap[listenerType.__instanceId];671 cc.arrayRemoveObject(_t._dirtyNodes, listenerType);672 var listeners = _t._nodeListenersMap[listenerType.__instanceId], i;673 if (listeners) {674 var listenersCopy = cc.copyArray(listeners);675 for (i = 0; i < listenersCopy.length; i++)676 _t.removeListener(listenersCopy[i]);677 listenersCopy.length = 0;678 }679 // Bug fix: ensure there are no references to the node in the list of listeners to be added.680 // If we find any listeners associated with the destroyed node in this list then remove them.681 // This is to catch the scenario where the node gets destroyed before it's listener682 // is added into the event dispatcher fully. This could happen if a node registers a listener683 // and gets destroyed while we are dispatching an event (touch etc.)684 var locToAddedListeners = _t._toAddedListeners;685 for (i = 0; i < locToAddedListeners.length; ) {686 var listener = locToAddedListeners[i];687 if (listener._getSceneGraphPriority() == listenerType) {688 listener._setSceneGraphPriority(null); // Ensure no dangling ptr to the target node.689 listener._setRegistered(false);690 locToAddedListeners.splice(i, 1);691 } else692 ++i;693 }694 if (recursive === true) {695 var locChildren = listenerType.getChildren(), len;696 for (i = 0, len = locChildren.length; i< len; i++)697 _t.removeListeners(locChildren[i], true);698 }699 } else {700 if (listenerType == cc.EventListener.TOUCH_ONE_BY_ONE)701 _t._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID);702 else if (listenerType == cc.EventListener.TOUCH_ALL_AT_ONCE)703 _t._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID);704 else if (listenerType == cc.EventListener.MOUSE)705 _t._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID);706 else if (listenerType == cc.EventListener.ACCELERATION)707 _t._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID);708 else if (listenerType == cc.EventListener.KEYBOARD)709 _t._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID);710 else711 cc.log(cc._LogInfos.eventManager_removeListeners);712 }713 },714 /**715 * Removes all custom listeners with the same event name716 * @param {string} customEventName717 */718 removeCustomListeners: function (customEventName) {719 this._removeListenersForListenerID(customEventName);720 },721 /**722 * Removes all listeners723 */724 removeAllListeners: function () {725 var locListeners = this._listenersMap, locInternalCustomEventIDs = this._internalCustomListenerIDs;726 for (var selKey in locListeners){727 if(locInternalCustomEventIDs.indexOf(selKey) === -1)728 this._removeListenersForListenerID(selKey);729 }730 },731 /**732 * Sets listener's priority with fixed value.733 * @param {cc.EventListener} listener734 * @param {Number} fixedPriority735 */736 setPriority: function (listener, fixedPriority) {737 if (listener == null)738 return;739 var locListeners = this._listenersMap;740 for (var selKey in locListeners) {741 var selListeners = locListeners[selKey];742 var fixedPriorityListeners = selListeners.getFixedPriorityListeners();743 if (fixedPriorityListeners) {744 var found = fixedPriorityListeners.indexOf(listener);745 if (found != -1) {746 if(listener._getSceneGraphPriority() != null)747 cc.log(cc._LogInfos.eventManager_setPriority);748 if (listener._getFixedPriority() !== fixedPriority) {749 listener._setFixedPriority(fixedPriority);750 this._setDirty(listener._getListenerID(), this.DIRTY_FIXED_PRIORITY);751 }752 return;753 }754 }755 }756 },757 /**758 * Whether to enable dispatching events759 * @param {boolean} enabled760 */761 setEnabled: function (enabled) {762 this._isEnabled = enabled;763 },764 /**765 * Checks whether dispatching events is enabled766 * @returns {boolean}767 */768 isEnabled: function () {769 return this._isEnabled;770 },771 /**772 * Dispatches the event, also removes all EventListeners marked for deletion from the event dispatcher list.773 * @param {cc.Event} event774 */775 dispatchEvent: function (event) {776 if (!this._isEnabled)777 return;778 this._updateDirtyFlagForSceneGraph();779 this._inDispatch++;780 if(!event || !event.getType)781 throw "event is undefined";782 if (event.getType() == cc.Event.TOUCH) {783 this._dispatchTouchEvent(event);784 this._inDispatch--;785 return;786 }787 var listenerID = cc.__getListenerID(event);788 this._sortEventListeners(listenerID);789 var selListeners = this._listenersMap[listenerID];790 if (selListeners != null)791 this._dispatchEventToListeners(selListeners, this._onListenerCallback, event);792 this._updateListeners(event);793 this._inDispatch--;794 },795 _onListenerCallback: function(listener, event){796 event._setCurrentTarget(listener._getSceneGraphPriority());797 listener._onEvent(event);798 return event.isStopped();799 },800 /**801 * Dispatches a Custom Event with a event name an optional user data802 * @param {string} eventName803 * @param {*} optionalUserData804 */805 dispatchCustomEvent: function (eventName, optionalUserData) {806 var ev = new cc.EventCustom(eventName);807 ev.setUserData(optionalUserData);808 this.dispatchEvent(ev);809 }810};811// The event helper812cc.EventHelper = function(){};813cc.EventHelper.prototype = {814 constructor: cc.EventHelper,815 apply: function ( object ) {816 object.addEventListener = cc.EventHelper.prototype.addEventListener;817 object.hasEventListener = cc.EventHelper.prototype.hasEventListener;818 object.removeEventListener = cc.EventHelper.prototype.removeEventListener;819 object.dispatchEvent = cc.EventHelper.prototype.dispatchEvent;820 },821 addEventListener: function ( type, listener, target ) {822 if ( this._listeners === undefined )823 this._listeners = {};824 var listeners = this._listeners;825 if ( listeners[ type ] === undefined )826 listeners[ type ] = [];827 if ( !this.hasEventListener(type, listener, target))828 listeners[ type ].push( {callback:listener, eventTarget: target} );829 },830 hasEventListener: function ( type, listener, target ) {831 if ( this._listeners === undefined )832 return false;833 var listeners = this._listeners;834 if ( listeners[ type ] !== undefined ) {835 for(var i = 0, len = listeners.length; i < len ; i++){836 var selListener = listeners[i];837 if(selListener.callback == listener && selListener.eventTarget == target)838 return true;839 }840 }841 return false;842 },843 removeEventListener: function( type, target){844 if ( this._listeners === undefined )845 return;846 var listeners = this._listeners;847 var listenerArray = listeners[ type ];848 if ( listenerArray !== undefined ) {849 for(var i = 0; i < listenerArray.length ; ){850 var selListener = listenerArray[i];851 if(selListener.eventTarget == target)852 listenerArray.splice( i, 1 );853 else854 i++855 }856 }857 },858 dispatchEvent: function ( event, clearAfterDispatch ) {859 if ( this._listeners === undefined )860 return;861 if(clearAfterDispatch == null)862 clearAfterDispatch = true;863 var listeners = this._listeners;864 var listenerArray = listeners[ event];865 if ( listenerArray !== undefined ) {866 var array = [];867 var length = listenerArray.length;868 for ( var i = 0; i < length; i ++ ) {869 array[ i ] = listenerArray[ i ];870 }871 for ( i = 0; i < length; i ++ ) {872 array[ i ].callback.call( array[i].eventTarget, this );873 }874 if(clearAfterDispatch)875 listenerArray.length = 0;876 }877 }...
EventBus.ts
Source:EventBus.ts
1///<reference path="../collections/List.ts"/>2///<reference path="../collections/KeyMap.ts"/>3module EventBus{4 var listeners:KeyMap<any> = new KeyMap('listeners');5 // add event listener6 export function addEventListener(type:string, callback:any):void{7 var typeExists:boolean = listeners.has(type);8 if(!typeExists){9 createType(type);10 }11 var typeListeners:12 List<any> = getTypeListeners(type);13 addTypeListener(callback, typeListeners);14 }15 // remove event listener16 export function removeEventListener(type:string, callback:any):void{17 var typeExists:boolean = listeners.has(type);18 if(!typeExists){19 return;20 }21 var typeListeners:List<any> = getTypeListeners(type);22 removeTypeListeners(callback, typeListeners);23 }24 export function dispatchEvent(type:string, eventData:any):void{25 var typeExists:boolean = listeners.has(type);26 if(!typeExists){27 return;28 }29 var typeListeners:List<any> = getTypeListeners(type);30 executeListenersCallback(typeListeners, eventData);31 }32 function executeListenersCallback(typeListeners:List<any>, eventData:any):void{33 var iterator:ListIterator = typeListeners.getIterator();34 while(iterator.hasNext()){35 var listenerCallback = iterator.next();36 listenerCallback.call(this, eventData);37 }38 }39 function getTypeListeners(type:string):List<any>{40 return listeners.get(type);41 }42 function createType(type:string):void{43 var typeListeners:List<any> = createTypeListeners(type);44 listeners.add(type, typeListeners);45 }46 function addTypeListener(callback:any, typeListeners:List<any>):void{47 typeListeners.add(callback);48 }49 function createTypeListeners(type:string):List<any>{50 return new List(type);51 }52 function removeTypeListeners(callback:any, typeListeners:List<any>):void{53 var iterator:ListIterator = typeListeners.getIterator();54 var currentTypeListeners:any[] = new Array();55 var index:number = -1;56 while(iterator.hasNext()){57 index++;58 var typeListener:any = iterator.next();59 if(callback.toString() == typeListener.toString()){60 currentTypeListeners.push(index);61 }62 }63 removeCurrentTypeListeners(currentTypeListeners, typeListeners);64 updateListeners(typeListeners);65 }66 function removeCurrentTypeListeners(currentTypeListeners:any[], typeListeners:List<any>):void{67 if(currentTypeListeners.length > 0){68 for(var i:number =0; i<currentTypeListeners.length; i++){69 var listenerToRemoveIndex:number = currentTypeListeners[i];70 typeListeners.remove(listenerToRemoveIndex);71 }72 }73 }74 function updateListeners(typeListeners:List<any>):void{75 if(typeListeners.size()==0){76 removeType(typeListeners);77 }78 }79 function removeType(typeListeners:List<any>):void{80 var type:string = typeListeners.getId();81 listeners.remove(type);82 }...
Using AI Code Generation
1import React from 'react';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { withInfo } from '@storybook/addon-info';5import Button from './Button';6storiesOf('Button', module)7 .addDecorator(withInfo)8 .add('with text', () => (9 <Button onClick={action('clicked')}>Hello Button</Button>10 ));11import React from 'react';12import PropTypes from 'prop-types';13const Button = ({ onClick, children }) => (14 <button onClick={onClick} type="button">15 {children}16);17Button.propTypes = {18};19export default Button;20 at Object.isExportDeclaration (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/babel-plugin-react-docgen/lib/index.js:59:12)21 at PluginPass.ExportNamedDeclaration (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/babel-plugin-react-docgen/lib/index.js:87:27)22 at newFn (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/visitors.js:193:21)23 at NodePath._call (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/path/context.js:53:20)24 at NodePath.call (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/path/context.js:40:17)25 at NodePath.visit (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/path/context.js:88:12)26 at TraversalContext.visitQueue (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/context.js:118:16)27 at TraversalContext.visitSingle (/Users/abhishek/Desktop/ReactJS/React-Redux-Boilerplate/node_modules/@babel/traverse/lib/context.js:90:19
Using AI Code Generation
1import { listeners } from 'storybook-root';2import { listeners } from 'storybook-root';3import { listeners } from 'storybook-root';4import { listeners } from 'storybook-root';5import { listeners } from 'storybook-root';6import { listeners } from 'storybook-root';7import { listeners } from 'storybook-root';8import { listeners } from 'storybook-root';9import { listeners } from 'storybook-root';10import { listeners } from 'storybook-root';11import { listeners } from 'storybook-root';12import { listeners } from 'storybook-root';13import { listeners } from 'storybook-root';14import { listeners } from 'storybook-root';
Using AI Code Generation
1const { listeners } = require('storybook-root');2listeners.add('test', (data) => {3 console.log(data);4});5listeners.remove('test');6listeners.removeAll();7listeners.has('test');8listeners.count();9jest.mock('storybook-root', () => {10 return {11 listeners: {12 add: jest.fn(),13 remove: jest.fn(),14 removeAll: jest.fn(),15 has: jest.fn(),16 count: jest.fn(),17 },18 };19});20const { listeners } = require('storybook-root');21listeners.add('test', (data) => {22 console.log(data);23});24listeners.remove('test');25listeners.removeAll();26listeners.has('test');27listeners.count();28const { listeners } = require('storybook-root');29listeners.add('test', (data) => {30 console.log(data);31});32listeners.remove('test');33listeners.removeAll();34listeners.has('test');35listeners.count();
Using AI Code Generation
1import { listeners } from "storybook-root";2import { storiesOf } from "@storybook/react";3import React from "react";4const stories = storiesOf("Button", module);5const Button = ({ onClick, children }) => (6 <button onClick={onClick}>{children}</button>7);8stories.add("with text", () => (9 <Button onClick={() => console.log("clicked")}>Click me</Button>10));11listeners.on("story", ({ name }) => console.log(`Story ${name} rendered`));12listeners.on("story", ({ name }) => console.log(`Story ${name} rendered`));13import "test.js";14import { listeners } from "storybook-root";15listeners.on("story", ({ name }) => console.log(`Story ${name} rendered`));16import { listeners } from "storybook-root";17listeners.on("story", ({ name }) => console.log(`Story ${name} rendered`));18 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {19 console.log("Knob changed", data);20 });21 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {22 console.log("Knob changed", data);23 });24 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {25 console.log("Knob changed", data);26 });27 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {28 console.log("Knob changed", data);29 });30 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {31 console.log("Knob changed", data);32 });33 window.parent.__STORYBOOK_ADDONS.channel.on("storybookjs/knobs/change", function(data) {34 console.log("Kn
Using AI Code Generation
1import { listeners } from 'storybook-root';2import { addListener } from '@storybook/addons';3listeners.forEach(listener => addListener(listener));4import { listeners } from 'storybook-root';5import { addListener } from '@storybook/addons';6listeners.forEach(listener => addListener(listener));7import { listeners } from 'storybook-root';8import { addListener } from '@storybook/addons';9listeners.forEach(listener => addListener(listener));10import { listeners } from 'storybook-root';11import { addListener } from '@storybook/addons';12listeners.forEach(listener => addListener(listener));13import { listeners } from 'storybook-root';14import { addListener } from '@storybook/addons';15listeners.forEach(listener => addListener(listener));16import { listeners } from 'storybook-root';17import { addListener } from '@storybook/addons';18listeners.forEach(listener => addListener(listener));19import { listeners } from 'storybook-root';20import { addListener } from '@storybook/addons';21listeners.forEach(listener => addListener(listener));22import { listeners } from 'storybook-root';23import { addListener } from '@storybook/addons';24listeners.forEach(listener => addListener(listener));25import { listeners } from 'storybook-root';26import { addListener } from '@storybook/addons';
Using AI Code Generation
1import { listeners } from 'storybook-root';2listeners.add('my-event', (data) => {3 console.log('my-event', data);4});5listeners.remove('my-event');6listeners.trigger('my-event', { foo: 'bar' });7listeners.trigger('my-event', { foo: 'bar' }, true);8listeners.trigger('my-event', { foo: 'bar' }, false);9listeners.trigger('my-event', { foo: 'bar' }, null);10listeners.trigger('my-event', { foo: 'bar' }, undefined);11listeners.trigger('my-event', { foo: 'bar' }, 0);12listeners.trigger('my-event', { foo: 'bar' }, 1);13listeners.trigger('my-event', { foo: 'bar' }, 'string');14listeners.trigger('my-event', { foo: 'bar' }, {});15listeners.trigger('my-event', { foo: 'bar' }, []);16listeners.trigger('my-event', { foo: 'bar' }, /regex/);17listeners.trigger('my-event', { foo: 'bar' }, new Date());18listeners.trigger('my-event', { foo: 'bar' }, () => {});19listeners.trigger('my-event', { foo: 'bar' }, Symbol('symbol'));20listeners.trigger('my-event', { foo: 'bar' }, new Error());21listeners.trigger('my-event', { foo: 'bar' }, new Map());22listeners.trigger('my-event', {
Using AI Code Generation
1import { listeners } from 'storybook-root';2listeners.on('event', (data) => {3 console.log('event', data);4});5import { listeners } from 'storybook-root';6listeners.on('event', (data) => {7 console.log('event', data);8});9import { listeners } from 'storybook-root';10listeners.on('event', (data) => {11 console.log('event', data);12});13import { listeners } from 'storybook-root';14listeners.on('event', (data) => {15 console.log('event', data);16});17import { listeners } from 'storybook-root';18listeners.on('event', (data) => {19 console.log('event', data);20});21import { listeners } from 'storybook-root';22listeners.on('event', (data) => {23 console.log('event', data);24});25import { listeners } from 'storybook-root';26listeners.on('event', (data) => {27 console.log('event', data);28});29import { listeners } from 'storybook-root';30listeners.on('event', (data) => {31 console.log('event', data);32});33import { listeners } from 'storybook-root';34listeners.on('event', (data) => {35 console.log('event', data);36});37import { listeners } from 'storybook-root';38listeners.on('event', (data) => {39 console.log('event', data);40});41import { listeners } from 'storybook-root';42listeners.on('event', (data) => {43 console.log('event', data);44});45import { listeners } from 'storybook-root';46listeners.on('event', (data) => {47 console.log('event', data);
Using AI Code Generation
1import { root } from 'storybook-root';2const listeners = root.listeners;3listeners.on('event', (data) => {4 console.log(data);5});6listeners.emit('event', 'data');7import { root } from 'storybook-root';8const listeners = root.listeners;9listeners.on('event', (data) => {10 console.log(data);11});12listeners.emit('event', 'data');13import { root } from 'storybook-root';14const listeners = root.listeners;15listeners.on('event', (data) => {16 console.log(data);17});18listeners.emit('event', 'data');19import { root } from 'storybook-root';20const listeners = root.listeners;21listeners.on('event', (data) => {22 console.log(data);23});24listeners.emit('event', 'data');25import { root } from 'storybook-root';26const listeners = root.listeners;27listeners.on('event', (data) => {28 console.log(data);29});30listeners.emit('event', 'data');31import { root } from 'storybook-root';32const listeners = root.listeners;33listeners.on('event', (data) => {34 console.log(data);35});36listeners.emit('event', 'data');37import { root } from 'storybook-root';38const listeners = root.listeners;39listeners.on('event', (data) => {40 console.log(data);41});42listeners.emit('event', 'data');43import { root } from 'storybook-root';44const listeners = root.listeners;45listeners.on('event', (data) => {46 console.log(data);47});48listeners.emit('event', 'data');49import { root } from 'storybook-root';50const listeners = root.listeners;51listeners.on('event', (data) => {52 console.log(data);53});54listeners.emit('event', 'data');55import
Using AI Code Generation
1import { listeners } from 'storybook-addon-web-components-knobs';2export default {3};4import { listeners } from 'storybook-addon-web-components-knobs';5export default {6};7import { listeners } from 'storybook-addon-web-components-knobs';8export default {9};10import { listeners } from 'storybook-addon-web-components-knobs';11export const test = () => ({12});13export class Test extends LitElement {14 static get listeners() {15 return {16 };17 }18 handleCustomEvent(e) {19 console.log(e.detail);20 }21}22export class Test extends LitElement {23 static get listeners() {24 return {25 };26 }27 handleCustomEvent(e) {28 console.log(e.detail);29 }30}31export class Test extends LitElement {32 static get listeners() {33 return {34 };35 }36 handleCustomEvent(e) {37 console.log(e.detail);38 }39}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!