Skip to content

Commit d607567

Browse files
authored
Merge pull request #3 from ChaosCoder/easierTesting
Easier testing
2 parents 617d875 + fa9df17 commit d607567

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Shouter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Shouter"
3-
s.version = "0.4.1"
3+
s.version = "0.5.0"
44
s.summary = "A type safe, thread safe and memory safe alternative for NotificationCenter"
55
s.homepage = "https://github.com/ChaosCoder/Shouter"
66
s.license = { :type => 'MIT', :file => 'LICENSE.md' }

Sources/Shouter/Shouter.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@
88

99
import Foundation
1010

11-
public class Shouter {
11+
public protocol ShouterType {
12+
func register<T>(_ type: T.Type, observer: T)
13+
func unregister<T>(_ type: T.Type, observer: T)
14+
func unregister<T>(_ type: T.Type)
15+
func notify<T>(_ type: T.Type, block: (T) -> Void)
16+
}
17+
18+
public class Shouter: ShouterType {
1219

1320
public static let `default` = Shouter()
1421

1522
fileprivate typealias Key = String
1623
fileprivate var observers: [Key: NSHashTable<AnyObject>] = [:]
17-
fileprivate let notificationQueue = DispatchQueue(label: "com.swift.notification.center.dispatch.queue", attributes: .concurrent)
24+
fileprivate let notificationQueue: DispatchQueue
25+
26+
public init(notificationQueue: DispatchQueue = DispatchQueue(label: "de.chaosspace.Shouter.dispatch.queue", attributes: .concurrent)) {
27+
self.notificationQueue = notificationQueue
28+
}
1829

1930
public func register<T>(_ type: T.Type, observer: T) {
2031
notificationQueue.sync(flags: .barrier) {

0 commit comments

Comments
 (0)