 
 import Foundation
 
-public protocol Event {
+public protocol EventBase {}
+public protocol Event: EventBase {}
+public protocol StickyEvent: EventBase {}
 
-}
-
-public protocol StickyEvent: Event {
-
-}
-
-public class Swen<EventType: Event> {
+public class Swen<EventType: EventBase> {
 
     fileprivate var listeners = [EventListener<EventType>]()
     public typealias EventListenerClosure = (_ event: EventType) -> Void


}

// MARK: public interface
public extension Swen {

    static func register(_ observer: AnyObject, onQueue queue: OperationQueue = .main, handler: @escaping EventListenerClosure) {
        instance().register(observer, onQueue: queue, handler: handler)

        instance().post(event)
    }

    static var sticky: EventType? {
        return instance().sticky
    }
    
}

// MARK: public sticky events interface
public extension Swen where EventType: StickyEvent {

    static func register(_ observer: AnyObject, onQueue queue: OperationQueue = .main, handler: @escaping EventListenerClosure) {
        instance().register(observer, onQueue: queue, handler: handler)
    }

    static func registerOnBackground(_ observer: AnyObject, handler: @escaping EventListenerClosure) {
        let queue = OperationQueue()
        queue.name = "com.sixt.Swen " + String(describing: EventType.self) + String(describing: observer)
        register(observer, onQueue: queue, handler: handler)
    }

    static func post(_ event: EventType) {
        instance().post(event)
    }

    static var sticky: EventType? {
        return instance().sticky
    }
    
}

// MARK: public interface
public extension Swen {

    static func unregister(_ observer: AnyObject) {
        instance().unregister(observer)
    }
    
}
