Skip to content

Commit 356e055

Browse files
committed
Added test project, orgenized classes in different files, ready to runble
1 parent c97265f commit 356e055

File tree

74 files changed

+3642
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3642
-578
lines changed
File renamed without changes.
File renamed without changes.

TopicEventBus/TopicEventBus.swift renamed to Classes/TopicEventBus.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Foundation
1010

1111
public protocol TopicEventBusType {
1212
func fire(event: TopicEvnet)
13-
func subscribe<T: TopicEvnet>(classType: T, topic: String) -> Listener
14-
func subscribe<T: TopicEvnet>(classType: T) -> Listener
13+
func subscribe<T: TopicEvnet>(callback: @escaping (T) -> Void) -> Listener
14+
func subscribe<T: TopicEvnet>(topic: String?, callback: @escaping (T) -> Void) -> Listener
1515
func terminate()
1616
}
1717

@@ -28,11 +28,11 @@ class EventSubscribtions {
2828

2929
typealias ClassName = NSString
3030

31-
class TopicEventBus {
31+
open class TopicEventBus: TopicEventBusType {
3232
private var subscribers = NSMapTable<ClassName, EventSubscribtions>.init(keyOptions: NSPointerFunctions.Options.strongMemory,
3333
valueOptions: NSPointerFunctions.Options.strongMemory )
3434

35-
func fire(event: TopicEvnet) {
35+
public func fire(event: TopicEvnet) {
3636
let className = String(describing: event)
3737
guard let subscribtions = self.subscribers.object(forKey: className as ClassName) else {
3838
return
@@ -51,11 +51,11 @@ class TopicEventBus {
5151
}
5252
}
5353

54-
func subscribe<T: TopicEvnet>(callback: @escaping (T) -> Void) -> Listener {
54+
public func subscribe<T: TopicEvnet>(callback: @escaping (T) -> Void) -> Listener {
5555
return self.subscribe(topic: nil, callback: callback)
5656
}
5757

58-
func subscribe<T: TopicEvnet>(topic: String?, callback: @escaping (T) -> Void) -> Listener {
58+
public func subscribe<T: TopicEvnet>(topic: String?, callback: @escaping (T) -> Void) -> Listener {
5959
let className = NSStringFromClass(T.self)
6060
if (self.subscribers.object(forKey: className as ClassName) == nil) {
6161
self.subscribers.setObject(EventSubscribtions(value: []), forKey: className as ClassName)
@@ -68,7 +68,7 @@ class TopicEventBus {
6868
return subscribtion
6969
}
7070

71-
func terminate() {
71+
public func terminate() {
7272
print("Terminating topic event bus")
7373
self.subscribers.removeAllObjects()
7474
}

ExampleProject/ExampleProject.xcodeproj/project.pbxproj

Lines changed: 797 additions & 0 deletions
Large diffs are not rendered by default.

TopicEventBus.xcodeproj/project.xcworkspace/contents.xcworkspacedata renamed to ExampleProject/ExampleProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>ExampleProject.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>4</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

ExampleProject/ExampleProject.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)