UNPKG

rizzo-next

Version:

The next generation of Lonely Planet's style guide and pattern library.

318 lines (291 loc) 30.1 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <base data-ice="baseUrl" href="../../../../"> <title data-ice="title">src/core/mixins/events.js | API Document</title> <link type="text/css" rel="stylesheet" href="css/style.css"> <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css"> <script src="script/prettify/prettify.js"></script> <script src="script/manual.js"></script> <link data-ice="userStyle" rel="stylesheet" href="user/css/0-docs.css"> </head> <body class="layout-container" data-ice="rootContainer"> <header> <a href="./">Home</a> <a href="identifiers.html">Reference</a> <a href="source.html">Source</a> <a href="test.html" data-ice="testLink">Test</a> <a data-ice="repoURL" href="https://github.com/lonelyplanet/rizzo-next.git" class="repo-url-github">Repository</a> <div class="search-box"> <span> <img src="./image/search.png"> <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span> </span> <ul class="search-result"></ul> </div> </header> <nav class="navigation" data-ice="nav"><div> <ul> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-rizzo">rizzo</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/action_sheet</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/action_sheet/index.js~ActionSheetComponent.html">ActionSheetComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-actionSheetComponent">actionSheetComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/article_body</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/article_body/index.js~ArticleBodyComponent.html">ArticleBodyComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/articles</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/articles/index.js~ArticlesComponent.html">ArticlesComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-articlesComponent">articlesComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/footer</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/footer/footer_component.js~Footer.html">Footer</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-footer">footer</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/header</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/header/header_component.js~Header.html">Header</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-header">header</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/hotels</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/hotels/hotels_widget.js~HotelsWidget.html">HotelsWidget</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-hotelsWidget">hotelsWidget</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/image_gallery</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/image_gallery/image_gallery.js~ImageGalleryComponent.html">ImageGalleryComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/login</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/login/login_manager.js~LoginManager.html">LoginManager</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/login/user.js~User.html">User</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/map</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/interactive-map.js~InteractiveMap.html">InteractiveMap</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/map_component.js~MapComponent.html">MapComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-MapActions">MapActions</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-MapAPI">MapAPI</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-interactiveMap">interactiveMap</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-mapComponent">mapComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-MapState">MapState</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/map/mapbox</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/mapbox/index.js~MapProvider.html">MapProvider</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/mapbox/markerset.js~MarkerSet.html">MarkerSet</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-mapProvider">mapProvider</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-markerSet">markerSet</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/map/views</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/about-panel.jsx~AboutPanel.html">AboutPanel</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/alert.jsx~AlertView.html">AlertView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/item.jsx~ItemView.html">ItemView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/main.jsx~MainView.html">MainView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/map.jsx~MapView.html">MapView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/panel.jsx~PanelView.html">PanelView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/pin.jsx~PinView.html">PinView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/sidebar-details.jsx~SidebarDetailsView.html">SidebarDetailsView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/sidebar-dropdown.jsx~SidebarDropdown.html">SidebarDropdown</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/sidebar-fetching.jsx~SidebarFetchingView.html">SidebarFetchingView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/sidebar.jsx~SidebarView.html">SidebarView</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/map/views/tab.jsx~TabView.html">TabView</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/masthead</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/masthead/masthead_component.js~MastheadComponent.html">MastheadComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/navigation</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/navigation/navigation_component.js~NavigationComponent.html">NavigationComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NavigationActions">NavigationActions</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-navigationComponent">navigationComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NavigationState">NavigationState</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/notification</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/notification/notification.js~Notification.html">Notification</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-notification">notification</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/overlay</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/overlay/index.js~Overlay.html">Overlay</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-overlay">overlay</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/related_guidebook</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/related_guidebook/index.js~RelatedGuidebookComponent.html">RelatedGuidebookComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-relatedGuidebookComponent">relatedGuidebookComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/search</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/search/search_component.js~SearchComponent.html">SearchComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SearchActions">SearchActions</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SearchApi">SearchApi</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-searchComponent">searchComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SearchServerActions">SearchServerActions</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SearchState">SearchState</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/search/search_item</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/search/search_item/index.js~SearchItemComponent.html">SearchItemComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-searchItemComponent">searchItemComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/slideshow</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/slideshow/slide_component.js~SlideComponent.html">SlideComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/slideshow/slideshow.js~Slideshow.html">Slideshow</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-slideComponent">slideComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/stacks</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/stacks/stack_component.js~Stack.html">Stack</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-StackActions">StackActions</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-stack">stack</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-StackState">StackState</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/sub_nav</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/sub_nav/index.js~SubNav.html">SubNav</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/tabs</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/tabs/tabs_component.js~Tabs.html">Tabs</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/things_to_do</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/things_to_do/things_to_do.js~ThingsToDo.html">ThingsToDo</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-thingsToDo">thingsToDo</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/tooltip</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/tooltip/tooltip.js~Tooltip.html">Tooltip</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-tooltip">tooltip</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/top_places</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/top_places/top_places_component.js~TopPlaces.html">TopPlaces</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-topPlaces">topPlaces</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/tours</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/tours/index.js~ToursComponent.html">ToursComponent</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-toursComponent">toursComponent</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/usabilla</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/usabilla/index.js~Usabilla.html">Usabilla</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-usabilla">usabilla</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components/video</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/video/brightcove.js~Brightcove.html">Brightcove</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/video/index.js~Video.html">Video</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/video/video_player.js~VideoPlayer.html">VideoPlayer</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-brightcove">brightcove</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-video">video</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-videoPlayer">videoPlayer</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">core</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/component.js~Component.html">Component</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/component_registry.js~ComponentRegistry.html">ComponentRegistry</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/cookie_util.js~CookieUtil.html">CookieUtil</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/logger.js~Logger.html">Logger</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/mobile_util.js~MobileUtil.html">MobileUtil</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/perf_monitor.js~PerfMonitor.html">PerfMonitor</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/rizzo.js~Rizzo.html">Rizzo</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/core/shop_cookie_util.js~ShopCookieUtil.html">ShopCookieUtil</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-Arkham">Arkham</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-mobileUtil">mobileUtil</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-shopCookieUtil">shopCookieUtil</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">core/decorators</div><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-channel">channel</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-publish">publish</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-subscribe">subscribe</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">core/mixins</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-Events">Events</a></span></span></li> <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">core/utils</div><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-highlight">highlight</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-getScrollbarWidth">getScrollbarWidth</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-mark">mark</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-measure">measure</a></span></span></li> </ul> </div> </nav> <div class="content" data-ice="content"><h1 data-ice="title">src/core/mixins/events.js</h1> <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">let each = require(&quot;lodash/collection/each&quot;), once = require(&quot;lodash/function/once&quot;), keys = require(&quot;lodash/object/keys&quot;), isEmpty = require(&quot;lodash/lang/isEmpty&quot;), uniqueId = require(&quot;lodash/utility/uniqueId&quot;), slice = Array.prototype.slice; // Regular expression used to split event strings. let eventSplitter = /\s+/; // Implement fancy features of the Events API such as multiple event // names `&quot;change blur&quot;` and jQuery-style event maps `{change: action}` // in terms of the existing API. function eventsApi(obj, action, name, rest) { if (!name) return true; // Handle event maps. if (typeof name === &quot;object&quot;) { for (let key in name) { obj[action].apply(obj, [key, name[key]].concat(rest)); } return false; } // Handle space separated event names. if (eventSplitter.test(name)) { let names = name.split(eventSplitter); for (let i = 0, l = names.length; i &lt; l; i++) { obj[action].apply(obj, [names[i]].concat(rest)); } return false; } return true; } // A difficult-to-believe, but optimized internal dispatch function for // triggering events. Tries to keep the usual cases speedy (most internal // Backbone events have 3 arguments). function triggerEvents(events, args) { let ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; switch (args.length) { case 0: while (++i &lt; l) (ev = events[i]).callback.call(ev.ctx); return; case 1: while (++i &lt; l) (ev = events[i]).callback.call(ev.ctx, a1); return; case 2: while (++i &lt; l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; case 3: while (++i &lt; l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; default: while (++i &lt; l) (ev = events[i]).callback.apply(ev.ctx, args); return; } } let Events = { // Bind an event to a `callback` function. Passing `&quot;all&quot;` will bind // the callback to all events fired. on: function(name, callback, context) { if (!eventsApi(this, &quot;on&quot;, name, [callback, context]) || !callback) return this; this._events || (this._events = {}); let events = this._events[name] || (this._events[name] = []); events.push({callback: callback, context: context, ctx: context || this}); return this; }, // Bind an event to only be triggered a single time. After the first time // the callback is invoked, it will be removed. once: function(name, callback, context) { if (!eventsApi(this, &quot;once&quot;, name, [callback, context]) || !callback) return this; let self = this; let onced = once(function() { self.off(name, once); callback.apply(this, arguments); }); onced._callback = callback; return this.on(name, onced, context); }, // Remove one or many callbacks. If `context` is null, removes all // callbacks with that function. If `callback` is null, removes all // callbacks for the event. If `name` is null, removes all bound // callbacks for all events. off: function(name, callback, context) { let retain, ev, events, names, i, l, j, k; if (!this._events || !eventsApi(this, &quot;off&quot;, name, [callback, context])) return this; if (!name &amp;&amp; !callback &amp;&amp; !context) { this._events = void 0; return this; } names = name ? [name] : keys(this._events); for (i = 0, l = names.length; i &lt; l; i++) { name = names[i]; if (events = this._events[name]) { this._events[name] = retain = []; if (callback || context) { for (j = 0, k = events.length; j &lt; k; j++) { ev = events[j]; if ((callback &amp;&amp; callback !== ev.callback &amp;&amp; callback !== ev.callback._callback) || (context &amp;&amp; context !== ev.context)) { retain.push(ev); } } } if (!retain.length) delete this._events[name]; } } return this; }, // Trigger one or many events, firing all bound callbacks. Callbacks are // passed the same arguments as `trigger` is, apart from the event name // (unless you&apos;re listening on `&quot;all&quot;`, which will cause your callback to // receive the true name of the event as the first argument). trigger: function(name) { if (!this._events) return this; let args = slice.call(arguments, 1); if (!eventsApi(this, &quot;trigger&quot;, name, args)) return this; let events = this._events[name]; let allEvents = this._events.all; if (events) triggerEvents(events, args); if (allEvents) triggerEvents(allEvents, arguments); return this; }, // Tell this object to stop listening to either specific events ... or // to every object it&apos;s currently listening to. stopListening: function(obj, name, callback) { let listeningTo = this._listeningTo; if (!listeningTo) return this; let remove = !name &amp;&amp; !callback; if (!callback &amp;&amp; typeof name === &quot;object&quot;) callback = this; if (obj) (listeningTo = {})[obj._listenId] = obj; for (let id in listeningTo) { obj = listeningTo[id]; obj.off(name, callback, this); if (remove || isEmpty(obj._events)) delete this._listeningTo[id]; } return this; } }; let listenMethods = {listenTo: &quot;on&quot;, listenToOnce: &quot;once&quot;}; // Inversion-of-control versions of `on` and `once`. Tell *this* object to // listen to an event in another object ... keeping track of what it&apos;s // listening to. each(listenMethods, function(implementation, method) { Events[method] = function(obj, name, callback) { let listeningTo = this._listeningTo || (this._listeningTo = {}); let id = obj._listenId || (obj._listenId = uniqueId(&quot;l&quot;)); listeningTo[id] = obj; if (!callback &amp;&amp; typeof name === &quot;object&quot;) callback = this; obj[implementation](name, callback, this); return this; }; }); // Aliases for backwards compatibility. Events.bind = Events.on; Events.unbind = Events.off; export default Events; </code></pre> </div> <footer class="footer"> Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(0.4.3)</span></a> </footer> <script src="script/search_index.js"></script> <script src="script/search.js"></script> <script src="script/pretty-print.js"></script> <script src="script/inherited-summary.js"></script> <script src="script/test-summary.js"></script> <script src="script/inner-link.js"></script> <script src="script/patch-for-local.js"></script> </body> </html>