0001    // EventListener.swift
0002    //
0003    // The MIT License (MIT)
0004    //
0005    // Copyright (c) 2015 Zewo
0006    //
0007    // Permission is hereby granted, free of charge, to any person obtaining a copy
0008    // of this software and associated documentation files (the "Software"), to deal
0009    // in the Software without restriction, including without limitation the rights
0010    // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0011    // copies of the Software, and to permit persons to whom the Software is
0012    // furnished to do so, subject to the following conditions:
0013    //
0014    // The above copyright notice and this permission notice shall be included in all
0015    // copies or substantial portions of the Software.
0016    //
0017    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0018    // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0019    // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0020    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0021    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0022    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0023    // SOFTWARE.
0024    
0025    public final class EventListener
EventEmitter.swift:26
	private var listeners: [EventListener<T>] = []
EventEmitter.swift:28
	public func listen(times times: Int = -1, listener: EventListener<T>.Listener) -> EventListener<T> {
EventEmitter.swift:28
	public func listen(times times: Int = -1, listener: EventListener<T>.Listener) -> EventListener<T> {
EventEmitter.swift:29
		let listener = EventListener<T>(calls: times, listener: listener)
<T
EventListener.swift:26
	public typealias Listener = T -> ()
EventListener.swift:37
	public func call(event: T) -> Bool {
> { 0026 public typealias Listener
EventEmitter.swift:28
	public func listen(times times: Int = -1, listener: EventListener<T>.Listener) -> EventListener<T> {
EventListener.swift:28
	private let listener: Listener
EventListener.swift:32
	internal init(calls: Int, listener: Listener) {
= T -> () 0027 0028 private let listener
EventListener.swift:34
		self.listener = listener
EventListener.swift:40
		listener(event)
: Listener 0029 private var calls
EventListener.swift:33
		self.calls = calls
EventListener.swift:38
		calls -= 1
EventListener.swift:39
		if calls == 0 { active = false }
: Int 0030 var active
EventEmitter.swift:35
		listeners = listeners.filter({ $0.active })
EventListener.swift:39
		if calls == 0 { active = false }
EventListener.swift:41
		return active
EventListener.swift:45
		active = false
= true 0031 0032 internal init(calls: Int, listener: Listener) { 0033 self.calls = calls 0034 self.listener = listener 0035 } 0036 0037 public func call
EventEmitter.swift:36
		listeners.forEach({ $0.call(event) })
(event: T) -> Bool { 0038 calls -= 1 0039 if calls == 0 { active = false } 0040 listener(event) 0041 return active 0042 } 0043 0044 public func stop() { 0045 active = false 0046 } 0047 } 0048