Sets the current target that the manager should bind events to.
(target: MapEventManagerTarget)
| 98 | |
| 99 | /** Sets the current target that the manager should bind events to. */ |
| 100 | setTarget(target: MapEventManagerTarget) { |
| 101 | const currentTarget = this._targetStream.value; |
| 102 | |
| 103 | if (target === currentTarget) { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | // Clear the listeners from the pre-existing target. |
| 108 | if (currentTarget) { |
| 109 | this._clearListeners(); |
| 110 | this._pending = []; |
| 111 | } |
| 112 | |
| 113 | this._targetStream.next(target); |
| 114 | |
| 115 | // Add the listeners that were bound before the map was initialized. |
| 116 | this._pending.forEach(subscriber => subscriber.observable.subscribe(subscriber.observer)); |
| 117 | this._pending = []; |
| 118 | } |
| 119 | |
| 120 | /** Destroys the manager and clears the event listeners. */ |
| 121 | destroy() { |
no test coverage detected