(eventType: string, options: EventsFnOptions = {})
| 143 | } |
| 144 | |
| 145 | public events(eventType: string, options: EventsFnOptions = {}): Stream<Event> { |
| 146 | if (typeof eventType !== `string`) { |
| 147 | throw new Error(`DOM driver's events() expects argument to be a ` + |
| 148 | `string representing the event type to listen for.`); |
| 149 | } |
| 150 | const useCapture: boolean = determineUseCapture(eventType, options); |
| 151 | |
| 152 | const namespace = this._namespace; |
| 153 | const fullScope = getFullScope(namespace); |
| 154 | const keyParts = [eventType, useCapture]; |
| 155 | if (fullScope) { |
| 156 | keyParts.push(fullScope); |
| 157 | } |
| 158 | const key = keyParts.join('~'); |
| 159 | const domSource = this; |
| 160 | |
| 161 | let rootElement$: Stream<Element>; |
| 162 | if (fullScope) { |
| 163 | rootElement$ = this._rootElement$ |
| 164 | .compose(filterBasedOnIsolation(domSource, fullScope)); |
| 165 | } else { |
| 166 | rootElement$ = this._rootElement$.take(2); |
| 167 | } |
| 168 | |
| 169 | const event$: Stream<Event> = rootElement$ |
| 170 | .map(function setupEventDelegatorOnTopElement(rootElement) { |
| 171 | // Event listener just for the root element |
| 172 | if (!namespace || namespace.length === 0) { |
| 173 | return fromEvent(rootElement, eventType, useCapture); |
| 174 | } |
| 175 | |
| 176 | // Event listener on the origin element as an EventDelegator |
| 177 | const delegators = domSource._delegators; |
| 178 | const origin = domSource._isolateModule.getElement(fullScope) || rootElement; |
| 179 | let delegator: EventDelegator; |
| 180 | if (delegators.has(key)) { |
| 181 | delegator = delegators.get(key) as EventDelegator; |
| 182 | delegator.updateOrigin(origin); |
| 183 | } else { |
| 184 | delegator = new EventDelegator( |
| 185 | origin, eventType, useCapture, domSource._isolateModule, |
| 186 | ); |
| 187 | delegators.set(key, delegator); |
| 188 | } |
| 189 | if (fullScope) { |
| 190 | domSource._isolateModule.addEventDelegator(fullScope, delegator); |
| 191 | } |
| 192 | |
| 193 | const subject = delegator.createDestination(namespace); |
| 194 | return subject; |
| 195 | }) |
| 196 | .flatten(); |
| 197 | |
| 198 | const out: DevToolEnabledSource & Stream<Event> = adapt(event$); |
| 199 | out._isCycleSource = domSource._name; |
| 200 | return out; |
| 201 | } |
| 202 |
nothing calls this directly
no test coverage detected