├── docs ├── img │ ├── gh.png │ ├── carat.png │ └── dash.png ├── docsets │ ├── SwiftyEventBus.tgz │ └── SwiftyEventBus.docset │ │ └── Contents │ │ ├── Resources │ │ ├── docSet.dsidx │ │ └── Documents │ │ │ ├── img │ │ │ ├── dash.png │ │ │ ├── gh.png │ │ │ └── carat.png │ │ │ ├── js │ │ │ └── jazzy.js │ │ │ ├── css │ │ │ └── highlight.css │ │ │ ├── search.json │ │ │ ├── Enums │ │ │ └── EventBusPostError.html │ │ │ ├── Protocols │ │ │ ├── EventBusSafety.html │ │ │ ├── EventPresentable.html │ │ │ └── EventBusPostable.html │ │ │ ├── Extensions │ │ │ ├── Reactive.html │ │ │ ├── EventBusPureMiddleWare.html │ │ │ └── EventBusDangerMiddleWare.html │ │ │ └── Classes │ │ │ └── EventSubscription.html │ │ └── Info.plist ├── badge.svg ├── js │ └── jazzy.js ├── css │ ├── highlight.css │ └── jazzy.css ├── search.json ├── Enums │ └── EventBusPostError.html ├── Protocols │ ├── EventBusSafety.html │ ├── EventPresentable.html │ ├── EventBusPostable.html │ └── EventBusSafePostable.html ├── Extensions │ ├── Reactive.html │ ├── EventBusPureMiddleWare.html │ └── EventBusDangerMiddleWare.html └── Classes │ └── EventSubscription.html ├── Screenshots └── SwiftyEventBus-Logo.png ├── SwiftyEventBus.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── SwiftyEventBus.xcscheme ├── Scripts └── generate-docs.sh ├── .swiftlint.yml ├── SwiftyEventBus.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── .gitignore ├── SwiftyEventBus ├── Core │ ├── EventPresentable.swift │ ├── EventBusQueue.swift │ ├── EventSubscriber.swift │ ├── Features │ │ ├── EventBusSafety.swift │ │ ├── EventBusSticky.swift │ │ ├── EventBusMiddleware+Post.swift │ │ ├── EventBusPureMiddleWare+Observer.swift │ │ └── EventBusMiddleware.swift │ ├── EventBus+Observable.swift │ ├── EventBus+Postable.swift │ ├── EventSubscription.swift │ ├── EventDispatch.swift │ └── EventBus.swift ├── SwiftyEventBus.h ├── Rx │ ├── EventBus+Rx.swift │ └── EventSubscription+Rx.swift └── Info.plist ├── SwiftyEventBusTests ├── Info.plist ├── EventBusRxTests.swift ├── EventBusFeatureTests.swift ├── EventBusDispatchTests.swift ├── EventBusPriorityTests.swift └── EventBusTests.swift ├── SwiftyEventBus-macOSTests ├── Info.plist └── SwiftyEventBus_macOSTests.swift ├── SwiftyEventBus-tvOSTests ├── Info.plist └── SwiftyEventBus_tvOSTests.swift ├── SwiftyEventBus.podspec ├── SwiftyEventBusRx.podspec ├── Podfile.lock ├── LICENSE ├── Podfile ├── .travis.yml └── README.md /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/img/gh.png -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/docsets/SwiftyEventBus.tgz -------------------------------------------------------------------------------- /Screenshots/SwiftyEventBus-Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/Screenshots/SwiftyEventBus-Logo.png -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/docSet.dsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/docsets/SwiftyEventBus.docset/Contents/Resources/docSet.dsidx -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/gh.png -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maru-zhang/SwiftyEventBus/HEAD/docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/img/carat.png -------------------------------------------------------------------------------- /SwiftyEventBus.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Scripts/generate-docs.sh: -------------------------------------------------------------------------------- 1 | jazzy \ 2 | --clean \ 3 | --author Maru \ 4 | --author_url https://github.com/Maru-zhang \ 5 | --github_url https://github.com/Maru-zhang/SwiftyEventBus \ 6 | --xcodebuild-arguments -scheme,SwiftyEventBus \ 7 | --documentation=Docs/*.md 8 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - type_name 3 | - trailing_whitespace 4 | - identifier_name 5 | - line_length 6 | - function_body_length 7 | - control_statement 8 | excluded: # paths to ignore during linting. Takes precedence over `included`. 9 | - Carthage 10 | - Pods -------------------------------------------------------------------------------- /SwiftyEventBus.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SwiftyEventBus.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftyEventBus.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | .bundle 22 | Carthage 23 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventPresentable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventPresentable.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/1. 6 | // 7 | 8 | import Foundation 9 | 10 | /// Get unique string for `T` type 11 | /// 12 | /// - Parameter type: type `T` 13 | /// - Returns: a string instance that present `T` 14 | public func EventID(_ type: T.Type) -> String { 15 | return String(reflecting: type) 16 | } 17 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventBusQueue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusQueue.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/8/1. 6 | // Copyright © 2018 Alloc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class EventBusBuffQueue { 12 | 13 | var map = [String: Any?]() 14 | 15 | func enqueue(_ cargo: T) { 16 | map[EventID(T.self)] = cargo 17 | } 18 | 19 | func dequeue() -> T? { 20 | return map[EventID(T.self)] as? T 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventSubscriber.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventSubscriber.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/1. 6 | // 7 | 8 | import Foundation 9 | 10 | public class EventSubscriber: NSObject { 11 | 12 | let eventHandler: (T) -> Void 13 | 14 | let mode: DispatchMode 15 | let priority: EventBusPriority 16 | 17 | init(mode: DispatchMode, priority: EventBusPriority = .default, eventHandler: @escaping (T) -> Void) { 18 | self.mode = mode 19 | self.priority = priority 20 | self.eventHandler = eventHandler 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SwiftyEventBus/SwiftyEventBus.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyEventBus.h 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/22. 6 | // Copyright © 2018 souche. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for SwiftyEventBus. 12 | FOUNDATION_EXPORT double SwiftyEventBusVersionNumber; 13 | 14 | //! Project version string for SwiftyEventBus. 15 | FOUNDATION_EXPORT const unsigned char SwiftyEventBusVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | -------------------------------------------------------------------------------- /SwiftyEventBus/Rx/EventBus+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBus+Rx.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/5. 6 | // 7 | 8 | import Foundation 9 | import RxSwift 10 | import SwiftyEventBus 11 | 12 | extension EventBus: ReactiveCompatible {} 13 | 14 | public extension Reactive where Base: EventBus { 15 | 16 | /// Reactive wrapper for `register(on:)` 17 | func register(_ type: T.Type) -> Observable { 18 | return Observable.create({ (observer) -> Disposable in 19 | return self.base.register(messageEvent: { (cargo) in 20 | observer.onNext(cargo) 21 | }) 22 | }) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SwiftyEventBus/Rx/EventSubscription+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventSubscription+Rx.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/5. 6 | // 7 | 8 | import Foundation 9 | import RxSwift 10 | import SwiftyEventBus 11 | 12 | extension EventSubscription: Disposable { 13 | 14 | public func dispose() { 15 | objc_sync_enter(self) 16 | defer { 17 | objc_sync_exit(self) 18 | } 19 | let identifier = EventID(T.self) 20 | if var set = eventBus.observers[identifier] as? Set> { 21 | set.remove(entity) 22 | eventBus.observers[identifier] = set 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/Features/EventBusSafety.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusSafety.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/7/31. 6 | // Copyright © 2018 souche. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol EventBusSafety { 12 | var safe: EventBusSafePostable { get } 13 | } 14 | 15 | extension EventBus: EventBusSafety { 16 | 17 | public var safe: EventBusSafePostable { 18 | return EventBusDangerMiddleWare(host: self, feautre: .safety) 19 | } 20 | } 21 | 22 | extension EventBusMiddleWare: EventBusSafety { 23 | 24 | public var safe: EventBusSafePostable { 25 | return EventBusDangerMiddleWare(host: host, feautre: .safety) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/Features/EventBusSticky.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusSticky.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/7/31. 6 | // 7 | 8 | import Foundation 9 | 10 | public typealias EventBusMiddle = EventBusPostable & EventBusObservable 11 | 12 | public protocol EventBusSticky { 13 | var stick: EventBusMiddle { get } 14 | } 15 | 16 | extension EventBus: EventBusSticky { 17 | 18 | public var stick: EventBusMiddle { 19 | return EventBusPureMiddleWare(host: self, feautre: .sticky) 20 | } 21 | } 22 | 23 | extension EventBusMiddleWare: EventBusSticky { 24 | 25 | public var stick: EventBusMiddle { 26 | return EventBusPureMiddleWare(host: host, feautre: .sticky) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.jazzy.swiftyeventbus 7 | CFBundleName 8 | SwiftyEventBus 9 | DocSetPlatformFamily 10 | swiftyeventbus 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | isJavaScriptEnabled 16 | 17 | DashDocSetFamily 18 | dashtoc 19 | 20 | 21 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventBus+Observable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBus+Observable.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/4/30. 6 | // 7 | 8 | import Foundation 9 | 10 | public protocol EventBusObservable { 11 | 12 | /// Register a message event for specify DataStruct 13 | /// 14 | /// - Parameters: 15 | /// - mode: The dispatch model for subscribe 16 | /// - priority: a closure that use `T` as only param 17 | /// - messageEvent: a closure that use `T` as only param 18 | /// - Returns: A instance of `EventSubscription`, that hold the subscriber 19 | func register(on mode: DispatchMode, 20 | priority: EventBusPriority, 21 | messageEvent: @escaping (T) -> Void) -> EventSubscription 22 | } 23 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SwiftyEventBus-macOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SwiftyEventBus-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SwiftyEventBus.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SwiftyEventBus' 3 | s.version = '1.0.2' 4 | s.summary = 'SwiftyEventBus is a publish/subscribe event bus for iOS and Swift.' 5 | s.homepage = 'https://github.com/Maru-zhang/SwiftyEventBus' 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = { 'Maru-zhang' => 'maru-zhang@foxmail.com' } 8 | s.source = { :git => 'https://github.com/Maru-zhang/SwiftyEventBus.git', :tag => s.version.to_s } 9 | 10 | s.ios.deployment_target = "8.0" 11 | s.osx.deployment_target = "10.10" 12 | s.tvos.deployment_target = "9.0" 13 | s.watchos.deployment_target = "3.0" 14 | 15 | s.swift_version = ['4.0', '4.2', '5.0'] 16 | s.source_files = 'SwiftyEventBus/Core/**/*.swift' 17 | end 18 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventBus+Postable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Postable.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/4/30. 6 | // 7 | 8 | import Foundation 9 | 10 | /// The error for posting event 11 | /// 12 | /// - useless: post a message that no subscriber observing 13 | public enum EventBusPostError: Error { 14 | case useless 15 | } 16 | 17 | public protocol EventBusPostable { 18 | 19 | /// Post a value to all subsctiber 20 | /// 21 | /// - Parameter cargo: The playload of any type 22 | func post(_ cargo: T) 23 | } 24 | 25 | public protocol EventBusSafePostable { 26 | 27 | /// Safe post a value to all subscriber, 28 | /// make sure there is one subscriber at least 29 | /// 30 | /// - Parameter cargo: The playload of any type 31 | func post(_ cargo: T) throws 32 | } 33 | -------------------------------------------------------------------------------- /SwiftyEventBus/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftyEventBusRx.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SwiftyEventBusRx' 3 | s.version = '1.0.2' 4 | s.summary = 'SwiftyEventBus is a publish/subscribe event bus for iOS and Swift.' 5 | s.homepage = 'https://github.com/Maru-zhang/SwiftyEventBus' 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = { 'Maru-zhang' => 'maru-zhang@foxmail.com' } 8 | s.source = { :git => 'https://github.com/Maru-zhang/SwiftyEventBus.git', :tag => s.version.to_s } 9 | 10 | s.ios.deployment_target = "8.0" 11 | s.osx.deployment_target = "10.10" 12 | s.tvos.deployment_target = "9.0" 13 | s.watchos.deployment_target = "3.0" 14 | 15 | s.swift_version = '5.0' 16 | s.source_files = 'SwiftyEventBus/Rx/**/*.swift' 17 | s.dependency 'SwiftyEventBus', '~>1.0.0' 18 | s.dependency 'RxSwift', '~>5.0.0' 19 | end 20 | 21 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventSubscription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventSubscription.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/1. 6 | // 7 | 8 | import Foundation 9 | 10 | public class EventSubscription { 11 | 12 | /// The subscriber who is working 13 | public let entity: EventSubscriber 14 | /// The EventBus that subscription holding 15 | public let eventBus: EventBus 16 | 17 | init(entity: EventSubscriber, eventBus: EventBus) { 18 | self.entity = entity 19 | self.eventBus = eventBus 20 | } 21 | 22 | deinit { 23 | objc_sync_enter(self) 24 | defer { 25 | objc_sync_exit(self) 26 | } 27 | let identifier = EventID(T.self) 28 | if var set = eventBus.observers[identifier] as? Set> { 29 | set.remove(entity) 30 | eventBus.observers[identifier] = set 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Nimble (8.0.2) 3 | - Quick (2.1.0) 4 | - RxSwift (5.0.0) 5 | - SwiftyEventBus (1.0.2) 6 | - SwiftyEventBusRx (1.0.2): 7 | - RxSwift (~> 5.0.0) 8 | - SwiftyEventBus (~> 1.0.0) 9 | 10 | DEPENDENCIES: 11 | - Nimble 12 | - Quick 13 | - SwiftyEventBus (from `./`) 14 | - SwiftyEventBusRx (from `./`) 15 | 16 | SPEC REPOS: 17 | https://github.com/CocoaPods/Specs.git: 18 | - Nimble 19 | - Quick 20 | - RxSwift 21 | 22 | EXTERNAL SOURCES: 23 | SwiftyEventBus: 24 | :path: "./" 25 | SwiftyEventBusRx: 26 | :path: "./" 27 | 28 | SPEC CHECKSUMS: 29 | Nimble: 622629381bda1dd5678162f21f1368cec7cbba60 30 | Quick: 4be43f6634acfa727dd106bdf3929ce125ffa79d 31 | RxSwift: 8b0671caa829a763bbce7271095859121cbd895f 32 | SwiftyEventBus: 2690d4fc4aab25f2c0cdc0644f111ecb6a326737 33 | SwiftyEventBusRx: acf40f353915fdf57599a4994b2fb97c18dbd255 34 | 35 | PODFILE CHECKSUM: 0d6ae83ea49c841ae2c954c189578b747eee881c 36 | 37 | COCOAPODS: 1.10.1 38 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/EventBusRxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusRxTests.swift 3 | // SwiftyEventBus_Tests 4 | // 5 | // Created by Maru on 2018/5/18. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import Quick 12 | import Nimble 13 | import SwiftyEventBus 14 | @testable import SwiftyEventBusRx 15 | 16 | class EventBusRxSpec: QuickSpec { 17 | 18 | override func spec() { 19 | describe("RxSwift extension") { 20 | it("subscribe string type", closure: { 21 | var bag: DisposeBag? = DisposeBag() 22 | waitUntil(action: { (done) in 23 | EventBus.default.rx.register(String.self) 24 | .subscribe(onNext: { (x) in 25 | expect(x).to(equal("foo")) 26 | done() 27 | }) 28 | .disposed(by: bag!) 29 | EventBus.default.post("foo") 30 | }) 31 | bag = nil 32 | }) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Maru-zhang 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/EventBusFeatureTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusFeatureTests.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/8/1. 6 | // Copyright © 2018 Alloc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Quick 11 | import Nimble 12 | @testable import SwiftyEventBus 13 | 14 | class EventBusFeatureTests: QuickSpec { 15 | 16 | var box = EventBusBox() 17 | 18 | override func spec() { 19 | describe("Eventbus advance feature") { 20 | describe("sticky event message", { 21 | it("receive foo message", closure: { 22 | let stickyFlag = "sticky" 23 | let bus = EventBus(domain: stickyFlag) 24 | bus.stick.post("foo") 25 | waitUntil(action: { (done) in 26 | bus.stick.register(on: .main, priority: .default, messageEvent: { (x: String) in 27 | expect(x).to(equal("foo")) 28 | done() 29 | }).release(by: self.box) 30 | }) 31 | }) 32 | }) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/Features/EventBusMiddleware+Post.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusMiddleware+EventBusPostable.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/8/1. 6 | // 7 | 8 | import Foundation 9 | 10 | extension EventBusPureMiddleWare: EventBusPostable { 11 | 12 | public func post(_ cargo: T) { 13 | let identifier = EventID(T.self) 14 | if (support(.sticky)) { 15 | host.replayBuff.enqueue(cargo) 16 | } 17 | guard let queue = host.observers[identifier] as? Set> else { 18 | return 19 | } 20 | performPost(with: queue, cargo: cargo) 21 | } 22 | } 23 | 24 | extension EventBusDangerMiddleWare: EventBusSafePostable { 25 | 26 | public func post(_ cargo: T) throws { 27 | let identifier = EventID(T.self) 28 | if (support(.sticky)) { 29 | host.replayBuff.enqueue(cargo) 30 | } 31 | guard let queue = host.observers[identifier] as? Set> else { 32 | return 33 | } 34 | if (support(.safety) && queue.isEmpty) { 35 | throw EventBusPostError.useless 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SwiftyEventBus-tvOSTests/SwiftyEventBus_tvOSTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyEventBus_tvOSTests.swift 3 | // SwiftyEventBus-tvOSTests 4 | // 5 | // Created by Maru on 2018/5/24. 6 | // Copyright © 2018 souche. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftyEventBus_tvOS 11 | 12 | class SwiftyEventBus_tvOSTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /SwiftyEventBus-macOSTests/SwiftyEventBus_macOSTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyEventBus_macOSTests.swift 3 | // SwiftyEventBus-macOSTests 4 | // 5 | // Created by Maru on 2018/5/24. 6 | // Copyright © 2018 souche. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftyEventBus_macOS 11 | 12 | class SwiftyEventBus_macOSTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /docs/badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | documentation 17 | 18 | 19 | documentation 20 | 21 | 22 | 33% 23 | 24 | 25 | 33% 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/Features/EventBusPureMiddleWare+Observer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusPureMiddleWare+Observer.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/8/1. 6 | // Copyright © 2018 Alloc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension EventBusMiddleWare: EventBusObservable { 12 | 13 | public func register(on mode: DispatchMode = .same, priority: EventBusPriority = .`default`, messageEvent: @escaping (T) -> Void) -> EventSubscription { 14 | let identifier = EventID(T.self) 15 | let subscriber = EventSubscriber(mode: mode, priority: priority, eventHandler: messageEvent) 16 | let subscription = EventSubscription(entity: subscriber, eventBus: host) 17 | if (support(.sticky)) { 18 | if let previousCargo: T = host.replayBuff.dequeue() { 19 | messageEvent(previousCargo) 20 | } 21 | } 22 | if var queue4T = host.observers[identifier] as? Set> { 23 | queue4T.insert(subscriber) 24 | host.observers[identifier] = queue4T 25 | } else { 26 | host.observers[identifier] = Set>(arrayLiteral: subscriber) 27 | } 28 | return subscription 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | 3 | target 'SwiftyEventBus' do 4 | platform :ios, '8.0' 5 | use_frameworks! 6 | end 7 | 8 | target 'SwiftyEventBusTests' do 9 | platform :ios, '8.0' 10 | use_frameworks! 11 | pod 'Quick' 12 | pod 'Nimble' 13 | pod 'SwiftyEventBus', :path=>'./' 14 | pod 'SwiftyEventBusRx', :path=>'./' 15 | end 16 | 17 | target 'SwiftyEventBus-watchOS' do 18 | platform :watchos, '4.3' 19 | use_frameworks! 20 | pod 'SwiftyEventBus', :path=>'./' 21 | pod 'SwiftyEventBusRx', :path=>'./' 22 | end 23 | 24 | target 'SwiftyEventBus-macOS' do 25 | platform :osx, '10.10' 26 | use_frameworks! 27 | pod 'SwiftyEventBus', :path=>'./' 28 | pod 'SwiftyEventBusRx', :path=>'./' 29 | end 30 | 31 | target 'SwiftyEventBus-macOSTests' do 32 | platform :osx, '10.10' 33 | use_frameworks! 34 | pod 'SwiftyEventBus', :path=>'./' 35 | pod 'SwiftyEventBusRx', :path=>'./' 36 | pod 'Quick' 37 | pod 'Nimble' 38 | end 39 | 40 | target 'SwiftyEventBus-tvOS' do 41 | platform :tvos, '9.0' 42 | use_frameworks! 43 | end 44 | 45 | target 'SwiftyEventBus-tvOSTests' do 46 | platform :tvos, '9.0' 47 | use_frameworks! 48 | pod 'SwiftyEventBus', :path=>'./' 49 | pod 'SwiftyEventBusRx', :path=>'./' 50 | pod 'Quick' 51 | pod 'Nimble' 52 | end 53 | -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | var tokenOffset = "15px"; 27 | var original = link.css('marginLeft') == tokenOffset; 28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration); 29 | $content = link.parent().parent().next(); 30 | $content.slideToggle(animationDuration); 31 | 32 | // Keeps the document from jumping to the hash. 33 | var href = $(this).attr('href'); 34 | if (history.pushState) { 35 | history.pushState({}, '', href); 36 | } else { 37 | location.hash = href; 38 | } 39 | event.preventDefault(); 40 | }); 41 | 42 | // Dumb down quotes within code blocks that delimit strings instead of quotations 43 | // https://github.com/realm/jazzy/issues/714 44 | $("code q").replaceWith(function () { 45 | return ["\"", $(this).contents(), "\""]; 46 | }); 47 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | var tokenOffset = "15px"; 27 | var original = link.css('marginLeft') == tokenOffset; 28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration); 29 | $content = link.parent().parent().next(); 30 | $content.slideToggle(animationDuration); 31 | 32 | // Keeps the document from jumping to the hash. 33 | var href = $(this).attr('href'); 34 | if (history.pushState) { 35 | history.pushState({}, '', href); 36 | } else { 37 | location.hash = href; 38 | } 39 | event.preventDefault(); 40 | }); 41 | 42 | // Dumb down quotes within code blocks that delimit strings instead of quotations 43 | // https://github.com/realm/jazzy/issues/714 44 | $("code q").replaceWith(function () { 45 | return ["\"", $(this).contents(), "\""]; 46 | }); 47 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode10.2 2 | language: objective-c 3 | before_install: true 4 | install: true 5 | cache: cocoapods 6 | podfile: Podfile 7 | xcode_scheme: SwiftyEventBus 8 | xcode_workspace: SwiftyEventBus.xcworkspace 9 | env: 10 | global: 11 | - FRAMEWORK_NAME=SwiftyEventBus 12 | before_install: 13 | - gem install cocoapods -v '1.7.4' 14 | before_script: 15 | - pod update RxSwift 16 | - pod update --no-repo-update 17 | script: 18 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace SwiftyEventBus.xcworkspace -scheme SwiftyEventBus -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.2' 19 | after_success: 20 | - bash <(curl -s https://codecov.io/bash) -t 05bd0885-f6ff-4e7a-b774-14ca8ea4badf 21 | before_deploy: 22 | - carthage build --no-skip-current 23 | - carthage archive $FRAMEWORK_NAME 24 | deploy: 25 | provider: releases 26 | api_key: 27 | secure: DjIQDHMOxg1ztrIG84hUTYPUjcTJr1l1PUf606oalFcWM2q2MS74nYfPEWkXd3dgUfiiyfnXDQBi9vh6jIdBd4fnvBMZ7/oqqr/fjkXvVzTNk8aay7I9g6kuI/oKShmkG++st+e9+2SOcLPrEJLN8JT8bi9X6IqtNCOMNYC51rJp4+ji5ej+fn8+SmVuO/CvBwtkRJXV96doVY4rJgBv4q6SdZMjS29N603cstr9YEi4tCKqZn6veBvWvohE1SjCfL2GPHFhKYps6/t65l9lIR3kIauLVTLxHD/hQq4SfKNVMhf+aR1LrQSae/R5K5Eo4p3KLXT3MLYsSEnG2ZE22dI8TEh8o+TtAwDP6kSK55QVmouZVTFUs4HbuAeuYrly5jAFrNlzc8LSF1Ej+SLGD0+/stQ7w60gkQAoiB8h0rFm+Pa2F5fFM1nUOkAme8xhoeR3aILg5E+gUCBXmUN3CwvKcPRMTZ341lNOqC3vb+vmRepP+1WZpfORNTbiDEhZYpaW0GPyuy1feEWmt/zVqG/X9kKCTaw4bQ9mmxQFdvPo4QwwxDTp62ReNTehboO3ybXbpPnwT/UTX8PwrJi41ojR1wETPEdsPQnuu0wQO/mYgAGcB0olq+ySool6qcSx7s3iTINEIRpR0XtugEC7uLjWPjl08L06b9SD+JY5Ibs= 28 | file: SwiftyEventBus.framework.zip 29 | on: 30 | repo: Maru-zhang/SwiftyEventBus 31 | branch: develop 32 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventDispatch.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventDispatch.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/5/8. 6 | // 7 | 8 | import Foundation 9 | import Dispatch 10 | 11 | /// The subscribe model when code excuting 12 | /// 13 | /// - same: dispatch block in same queue when post and subscribe 14 | /// - main: dispatch block in main queue only when subscribe 15 | public enum DispatchMode { 16 | case same 17 | case main 18 | } 19 | 20 | extension DispatchMode { 21 | 22 | /// The dispatch excutor for specify model 23 | var excuter: EventDispatchable { 24 | switch self { 25 | case .same: 26 | return SyncEventDispatch() 27 | case .main: 28 | return MainEventDispatch() 29 | } 30 | } 31 | } 32 | 33 | protocol EventDispatchable { 34 | var mode: DispatchMode { get } 35 | func run(with event: T, eventHandler: @escaping (T) -> Void) 36 | } 37 | 38 | struct SyncEventDispatch: EventDispatchable { 39 | 40 | var mode: DispatchMode { 41 | return .same 42 | } 43 | 44 | func run(with event: T, eventHandler: @escaping (T) -> Void) { 45 | eventHandler(event) 46 | } 47 | } 48 | 49 | struct MainEventDispatch: EventDispatchable { 50 | 51 | var mode: DispatchMode { 52 | return .main 53 | } 54 | 55 | func run(with event: T, eventHandler: @escaping (T) -> Void) { 56 | guard !DispatchQueue.isMain else { 57 | eventHandler(event) 58 | return 59 | } 60 | DispatchQueue.main.async { 61 | eventHandler(event) 62 | } 63 | } 64 | } 65 | 66 | extension DispatchQueue { 67 | 68 | static var mainToken: DispatchSpecificKey<()> = { 69 | let token = DispatchSpecificKey<()>() 70 | DispatchQueue.main.setSpecific(key: token, value: ()) 71 | return token 72 | }() 73 | 74 | static var isMain: Bool { 75 | return DispatchQueue.getSpecific(key: mainToken) != nil 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/EventBusDispatchTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusDispatchTests.swift 3 | // SwiftyEventBus_Tests 4 | // 5 | // Created by Maru on 2018/5/18. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Quick 11 | import Nimble 12 | @testable import SwiftyEventBus 13 | 14 | class EventBusDispatchTests: QuickSpec { 15 | 16 | override func spec() { 17 | describe("Dispatch queue tests") { 18 | var bag: EventSubscription! 19 | context("post on global queue", { 20 | context("dispatch on same queue", { 21 | it("got foo string result", closure: { 22 | waitUntil(action: { (done) in 23 | let token = DispatchSpecificKey() 24 | DispatchQueue.global().setSpecific(key: token, value: "global") 25 | DispatchQueue.global().sync { 26 | bag = EventBus.default.register(on: .same, messageEvent: { (x: String) in 27 | expect(DispatchQueue.getSpecific(key: token)).to(equal("global")) 28 | expect(x).to(equal("foo")) 29 | done() 30 | }) 31 | EventBus.default.post("foo") 32 | } 33 | }) 34 | bag.dispose() 35 | }) 36 | }) 37 | context("dispatch on main queue", { 38 | it("got foo string result", closure: { 39 | waitUntil(action: { (done) in 40 | DispatchQueue.global().async(execute: { 41 | bag = EventBus.default.register(on: .main, messageEvent: { (x: String) in 42 | expect(DispatchQueue.isMain).to(equal(true)) 43 | expect(x).to(equal("foo")) 44 | done() 45 | }) 46 | EventBus.default.post("foo") 47 | }) 48 | }) 49 | bag.dispose() 50 | }) 51 | }) 52 | }) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/EventBus.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBus.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/4/30. 6 | // 7 | 8 | import Foundation 9 | 10 | /// Default domain string for `EventBus` 11 | private let defaultDomain = "com.eventbus.swifty.domain.default" 12 | 13 | /// The priority of subscriber to revieve message 14 | /// 15 | /// - low: low leve priority, value is 1 16 | /// - default: default leve priority, value is 5 17 | /// - high: high leve priority, value is 10 18 | public enum EventBusPriority { 19 | 20 | case value(Int) 21 | 22 | public static var low: EventBusPriority { 23 | return .value(250) 24 | } 25 | 26 | public static var `default`: EventBusPriority { 27 | return .value(500) 28 | } 29 | 30 | public static var high: EventBusPriority { 31 | return .value(1000) 32 | } 33 | } 34 | 35 | public class EventBus { 36 | 37 | /// The default common `EventBus` instance 38 | public static let `default` = EventBus(domain: defaultDomain) 39 | 40 | /// The domain string that identify different `EventBus` instance 41 | public let domain: String 42 | 43 | /// The Dictionary that contain all `EventSubscriber` 44 | /// Discuss: we use string of type as key, and a set of `EventSubscriber` 45 | /// as value. when register or unregister, we just need to modify corresponding 46 | /// set. 47 | public var observers: [String: Any] 48 | 49 | /// The dictinary that contain the lastest N message event 50 | /// for support sticky and replay event 51 | let replayBuff = EventBusBuffQueue() 52 | 53 | /// The middleware that perform post and register actually 54 | var middleWare: EventBusPureMiddleWare { 55 | return EventBusPureMiddleWare(host: self, featureVal: 0) 56 | } 57 | 58 | /// The construction of `EventBus` 59 | /// 60 | /// - Parameter domain: The domain string 61 | public init(domain: String) { 62 | self.domain = domain 63 | self.observers = [String: Any]() 64 | } 65 | } 66 | 67 | extension EventBus: EventBusPostable { 68 | 69 | public func post(_ cargo: T) { 70 | middleWare.post(cargo) 71 | } 72 | } 73 | 74 | extension EventBus: EventBusObservable { 75 | 76 | public func register(on mode: DispatchMode = .same, priority: EventBusPriority = .`default`, messageEvent: @escaping (T) -> Void) -> EventSubscription { 77 | return middleWare.register(on: mode, priority: priority, messageEvent: messageEvent) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /SwiftyEventBus/Core/Features/EventBusMiddleware.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusMiddleware.swift 3 | // SwiftyEventBus 4 | // 5 | // Created by Maru on 2018/7/31. 6 | // 7 | 8 | import Foundation 9 | 10 | /// The advance feature for eventbus 11 | /// 12 | /// - safety: safety event that threw error when there is no subscriber 13 | /// - sticky: sticky event that receive previous message when subscribe 14 | enum EventBusFeature: UInt32 { 15 | case safety = 0x0001 16 | case sticky = 0x0002 17 | 18 | var isDangerFeature: Bool { 19 | let range: [EventBusFeature] = [.safety] 20 | return range.contains(self) 21 | } 22 | } 23 | 24 | class EventBusMiddleWare { 25 | 26 | init(host: EventBus, feautre: EventBusFeature) { 27 | self.host = host 28 | self.featureVal = feautre.rawValue 29 | } 30 | 31 | init(host: EventBus, featureVal: UInt32) { 32 | self.host = host 33 | self.featureVal = featureVal 34 | } 35 | 36 | static func build(host: EventBus, feautre: EventBusFeature) -> EventBusMiddleWare { 37 | return feautre.isDangerFeature ? EventBusDangerMiddleWare(host: host, feautre: feautre) : EventBusPureMiddleWare(host: host, feautre: feautre) 38 | } 39 | 40 | let host: EventBus 41 | 42 | var featureVal: UInt32 43 | 44 | /// Whether this middleware support specify feature 45 | /// 46 | /// - Parameter feature: specify feature 47 | /// - Returns: A Boolean value indicate support this feautre or not 48 | func support(_ feature: EventBusFeature) -> Bool { 49 | return (featureVal & feature.rawValue) > 0 50 | } 51 | 52 | func compose(by feature: EventBusFeature) -> EventBusMiddleWare { 53 | fatalError("this method should been override by subclass.") 54 | } 55 | 56 | func performPost(with queue: Set>, cargo: T) { 57 | /// the priority more largger, the time receive message more earlier. 58 | let sortedQueue = queue.sorted { (left, right) -> Bool in 59 | switch (left.priority, right.priority) { 60 | case (.value(let leftValue), .value(let rightValue)): 61 | return leftValue < rightValue 62 | } 63 | } 64 | for action in sortedQueue { 65 | let excuter = action.mode.excuter 66 | excuter.run(with: cargo, eventHandler: action.eventHandler) 67 | } 68 | } 69 | } 70 | 71 | class EventBusPureMiddleWare: EventBusMiddleWare { 72 | 73 | override func compose(by feature: EventBusFeature) -> EventBusMiddleWare { 74 | guard feature.isDangerFeature else { 75 | return EventBusPureMiddleWare(host: host, featureVal: featureVal | feature.rawValue) 76 | } 77 | return EventBusDangerMiddleWare(host: host, featureVal: featureVal | feature.rawValue) 78 | } 79 | } 80 | 81 | class EventBusDangerMiddleWare: EventBusMiddleWare { 82 | 83 | override func compose(by feature: EventBusFeature) -> EventBusMiddleWare { 84 | return EventBusDangerMiddleWare(host: host, featureVal: featureVal | feature.rawValue) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/EventBusPriorityTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusPriorityTests.swift 3 | // SwiftyEventBusTests 4 | // 5 | // Created by Maru on 2018/5/28. 6 | // Copyright © 2018 souche. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Quick 11 | import Nimble 12 | @testable import SwiftyEventBus 13 | 14 | class EventBusBox { 15 | var box: [Any] = [] 16 | func clear() { 17 | box.removeAll() 18 | } 19 | } 20 | 21 | extension EventSubscription { 22 | 23 | func release(by box: EventBusBox) { 24 | box.box.append(self) 25 | } 26 | } 27 | 28 | class EventBusPriorityTests: QuickSpec { 29 | 30 | var box = EventBusBox() 31 | 32 | override func spec() { 33 | describe("EventBus Priority Tests Spec") { 34 | describe("build-in enum usage", { 35 | it("high receive message first then default, low reveive message finally", closure: { 36 | waitUntil(action: { (done) in 37 | var lowFlag = false 38 | var defaultFlag = false 39 | var highFlag = false 40 | let group = DispatchGroup() 41 | let queue = DispatchQueue.global(qos: .utility) 42 | group.enter() 43 | queue.sync(execute: { 44 | EventBus.default.register(priority: .low, messageEvent: { (x: String) in 45 | expect(x).to(equal("foo")) 46 | expect(lowFlag).to(equal(false)) 47 | expect(defaultFlag).to(equal(false)) 48 | expect(highFlag).to(equal(false)) 49 | lowFlag = true 50 | group.leave() 51 | }).release(by: self.box) 52 | }) 53 | group.enter() 54 | queue.sync { 55 | EventBus.default.register(priority: .`default`, messageEvent: { (x: String) in 56 | expect(x).to(equal("foo")) 57 | expect(lowFlag).to(equal(true)) 58 | expect(defaultFlag).to(equal(false)) 59 | expect(highFlag).to(equal(false)) 60 | defaultFlag = true 61 | group.leave() 62 | }).release(by: self.box) 63 | } 64 | group.enter() 65 | queue.sync { 66 | EventBus.default.register(priority: .high, messageEvent: { (x: String) in 67 | expect(x).to(equal("foo")) 68 | expect(lowFlag).to(equal(true)) 69 | expect(defaultFlag).to(equal(true)) 70 | expect(highFlag).to(equal(false)) 71 | highFlag = true 72 | group.leave() 73 | }).release(by: self.box) 74 | } 75 | EventBus.default.post("foo") 76 | group.notify(qos: .default, flags: .inheritQoS, queue: DispatchQueue.main, execute: { 77 | expect(lowFlag).to(equal(true)) 78 | expect(defaultFlag).to(equal(true)) 79 | expect(highFlag).to(equal(true)) 80 | done() 81 | self.box.clear() 82 | }) 83 | }) 84 | }) 85 | }) 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /SwiftyEventBusTests/EventBusTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventBusTests.swift 3 | // SwiftyEventBus_Example 4 | // 5 | // Created by Maru on 2018/5/5. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | @testable import SwiftyEventBus 12 | 13 | let concurrentQueue = DispatchQueue(label: "com.eventbus.test.concurrent", attributes: .concurrent) 14 | 15 | class EventBusTests: QuickSpec { 16 | 17 | var stringBag: EventSubscription? 18 | var stringBGBag: EventSubscription? 19 | var intBag: EventSubscription? 20 | 21 | override func spec() { 22 | describe("A default eventbus") { 23 | describe("post string value", { 24 | it("get string message event", closure: { 25 | waitUntil(action: { (done) in 26 | self.stringBag = EventBus.default.register(messageEvent: { (x: String) in 27 | expect(x).to(equal("foo")) 28 | done() 29 | }) 30 | EventBus.default.post("foo") 31 | }) 32 | }) 33 | it("get two string message event", closure: { 34 | var count = 0 35 | waitUntil(action: { (done) in 36 | self.stringBag = EventBus.default.register(messageEvent: { (_) in 37 | count += 1 38 | if (count == 2) { 39 | done() 40 | } 41 | }) 42 | EventBus.default.post("foo") 43 | EventBus.default.post("foo") 44 | }) 45 | }) 46 | describe("register via concurrent queue", { 47 | it("get two string message event", closure: { 48 | waitUntil(action: { (done) in 49 | let semaphore = DispatchSemaphore(value: 1) 50 | concurrentQueue.async { 51 | semaphore.wait() 52 | self.stringBag = EventBus.default.register(messageEvent: { (x: String) in 53 | expect(x).to(equal("foo")) 54 | semaphore.signal() 55 | }) 56 | EventBus.default.post("foo") 57 | } 58 | concurrentQueue.async { 59 | semaphore.wait() 60 | self.stringBGBag = EventBus.default.register(messageEvent: { (x: String) in 61 | expect(x).to(equal("foo")) 62 | semaphore.signal() 63 | }) 64 | EventBus.default.post("foo") 65 | } 66 | done() 67 | }) 68 | }) 69 | }) 70 | }) 71 | describe("post int value", { 72 | it("get int message event", closure: { 73 | waitUntil(action: { (done) in 74 | self.intBag = EventBus.default.register(messageEvent: { (x: Int) in 75 | expect(x).to(equal(20)) 76 | done() 77 | }) 78 | EventBus.default.post(20) 79 | self.intBag = nil 80 | }) 81 | }) 82 | }) 83 | describe("safe post int value", { 84 | it("throw a error for post", closure: { 85 | expect { try EventBus.default.safe.post(100) }.to(throwError(EventBusPostError.useless)) 86 | }) 87 | }) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | 6 | # SwiftyEventBus 7 | 8 | ![](https://img.shields.io/badge/language-swift-orange.svg) 9 | [![CI Status](https://img.shields.io/travis/Maru-zhang/SwiftyEventBus.svg?style=flat)](https://travis-ci.org/Maru-zhang/SwiftyEventBus) 10 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 11 | [![codecov](https://codecov.io/gh/Maru-zhang/SwiftyEventBus/branch/master/graph/badge.svg)](https://codecov.io/gh/Maru-zhang/SwiftyEventBus) 12 | [![Version](https://img.shields.io/cocoapods/v/SwiftyEventBus.svg?style=flat)](https://cocoapods.org/pods/SwiftyEventBus) 13 | [![License](https://img.shields.io/cocoapods/l/SwiftyEventBus.svg?style=flat)](https://cocoapods.org/pods/SwiftyEventBus) 14 | [![Platform](https://img.shields.io/cocoapods/p/SwiftyEventBus.svg?style=flat)](https://cocoapods.org/pods/SwiftyEventBus) 15 | 16 | SwiftyEventBus is a publish/subscribe event bus for iOS and Swift. 17 | 18 | * simplifies the communication between components 19 | * make your code simple and elegant 20 | * type safe 21 | * more advance feature: safety event, sticky event, etc... 22 | 23 | In addition, if you want to read document, please click [here](https://maru-zhang.github.io/SwiftyEventBus/). 24 | 25 | ## Usage 26 | 27 | `SwiftyEventBus` is very easy to use, you just need two steps: 28 | 29 | #### 1.**Register** 30 | 31 | You can register in anywhere with any type, it will always observe until the `EventSubscription` object been released. 32 | 33 | ```swift 34 | class DemoViewController: UIViewController { 35 | 36 | var ob: EventSubscription! 37 | 38 | override func viewDidLoad() { 39 | super.viewDidLoad() 40 | ob = EventBus.`default`.register { (x: String) in 41 | print(x) 42 | } 43 | } 44 | } 45 | ``` 46 | 47 | #### 2.**Post** 48 | 49 | Finally, you just need to post any type that implement `EventPresentable`. 50 | 51 | 52 | ```swift 53 | EventBus.default.post("Foo") 54 | ``` 55 | 56 | ### Advance 57 | 58 | #### Safe Post 59 | 60 | Sometime, you maybe post a message that no one obseving, this is unsafety behaviour, then you can use this: 61 | 62 | ```swift 63 | EventBus.default.safePost("Foo") 64 | ``` 65 | 66 | If there is no observer subscribe this kind of message, `EventBus.default.safePost("Foo")` will raise `EventBusPostError.useless` Exception, you can catch it and handle this. 67 | 68 | ```swift 69 | /// handle EventBusPostError excetion 70 | do { 71 | try EventBus.default.safePost("foo") 72 | } catch { 73 | // do something 74 | } 75 | ``` 76 | 77 | ### Rx-Extension 78 | 79 | if you project using `RxSwift`, maybe you need this to bridge `SwiftyEventBus` to `Rx`. 80 | 81 | ```ruby 82 | pod 'SwiftyEventBus/Rx' 83 | ``` 84 | 85 | after that, you can use `SwiftyEventBus` in `RxSwift` world.🎉 86 | 87 | ```swift 88 | var bag: DisposeBag? = DisposeBag() 89 | EventBus.default.rx.register(String.self) 90 | .subscribe(onNext: { (x) in 91 | print(x) /// "foo" 92 | }) 93 | .disposed(by: bag!) 94 | EventBus.default.post("foo") 95 | ``` 96 | 97 | ## Example 98 | 99 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 100 | 101 | ## Installation 102 | 103 | ### CocoaPods 104 | 105 | SwiftyEventBus is available through [CocoaPods](https://cocoapods.org). To install 106 | it, simply add the following line to your Podfile: 107 | 108 | ```ruby 109 | pod 'SwiftyEventBus' 110 | ``` 111 | 112 | ### 113 | 114 | SwiftyEventBus is also available on `Carthage`, please add this to `Cartfile`: 115 | 116 | ``` 117 | github "Maru-zhang/SwiftyEventBus" 118 | ``` 119 | 120 | ## Author 121 | 122 | Maru-zhang, maru-zhang@foxmail.com 123 | 124 | ## License 125 | 126 | SwiftyEventBus is available under the MIT license. See the LICENSE file for more info. 127 | 128 | 129 | -------------------------------------------------------------------------------- /SwiftyEventBus.xcodeproj/xcshareddata/xcschemes/SwiftyEventBus.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 46 | 47 | 53 | 54 | 55 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 74 | 75 | 76 | 77 | 78 | 79 | 89 | 90 | 96 | 97 | 98 | 99 | 100 | 101 | 107 | 108 | 114 | 115 | 116 | 117 | 119 | 120 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/EventBusSafety.html#/s:14SwiftyEventBus0bC6SafetyP4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBusSafety"},"Protocols/EventPresentable.html#/s:14SwiftyEventBus0B11PresentableP17processIdentifierSSvpZ":{"name":"processIdentifier","abstract":"

Undocumented

","parent_name":"EventPresentable"},"Protocols/EventBusSafePostable.html#/s:14SwiftyEventBus0bC12SafePostableP4postyqd__KAA0B11PresentableRd__lF":{"name":"post(_:)","abstract":"

Safe post a value to all subscriber,","parent_name":"EventBusSafePostable"},"Protocols/EventBusPostable.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","abstract":"

Post a value to all subsctiber

","parent_name":"EventBusPostable"},"Protocols/EventBusObservable.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","abstract":"

Register a message event for specify DataStruct

","parent_name":"EventBusObservable"},"Protocols/EventBusObservable.html":{"name":"EventBusObservable","abstract":"

Undocumented

"},"Protocols/EventBusPostable.html":{"name":"EventBusPostable","abstract":"

Undocumented

"},"Protocols/EventBusSafePostable.html":{"name":"EventBusSafePostable","abstract":"

Undocumented

"},"Protocols/EventPresentable.html":{"name":"EventPresentable","abstract":"

Undocumented

"},"Protocols/EventBusSafety.html":{"name":"EventBusSafety","abstract":"

Undocumented

"},"Extensions/Reactive.html#/s:14SwiftyEventBus8registerXeXeF":{"name":"register(_:)","abstract":"

Reactive wrapper for register(on:)

","parent_name":"Reactive"},"Extensions/EventBusMiddleWare.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","parent_name":"EventBusMiddleWare"},"Extensions/EventBusMiddleWare.html#/s:14SwiftyEventBus0bC10MiddleWareC4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBusMiddleWare"},"Extensions/EventBusDangerMiddleWare.html#/s:14SwiftyEventBus0bC12SafePostableP4postyqd__KAA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBusDangerMiddleWare"},"Extensions/EventBusPureMiddleWare.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBusPureMiddleWare"},"Extensions/EventBusPureMiddleWare.html":{"name":"EventBusPureMiddleWare","abstract":"

Undocumented

"},"Extensions/EventBusDangerMiddleWare.html":{"name":"EventBusDangerMiddleWare","abstract":"

Undocumented

"},"Extensions/EventBusMiddleWare.html":{"name":"EventBusMiddleWare","abstract":"

Undocumented

"},"Extensions/Reactive.html":{"name":"Reactive"},"Enums/DispatchMode.html#/s:14SwiftyEventBus12DispatchModeO4sameA2CmF":{"name":"same","abstract":"

Undocumented

","parent_name":"DispatchMode"},"Enums/DispatchMode.html#/s:14SwiftyEventBus12DispatchModeO4mainA2CmF":{"name":"main","abstract":"

Undocumented

","parent_name":"DispatchMode"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO5valueACSicACmF":{"name":"value","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO3lowACvpZ":{"name":"low","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO7defaultACvpZ":{"name":"default","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO4highACvpZ":{"name":"high","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPostError.html#/s:14SwiftyEventBus0bC9PostErrorO7uselessA2CmF":{"name":"useless","abstract":"

Undocumented

","parent_name":"EventBusPostError"},"Enums/EventBusPostError.html":{"name":"EventBusPostError","abstract":"

The error for posting event

"},"Enums/EventBusPriority.html":{"name":"EventBusPriority","abstract":"

The priority of subscriber to revieve message

"},"Enums/DispatchMode.html":{"name":"DispatchMode","abstract":"

The subscribe model when code excuting

"},"Classes/EventSubscription.html#/s:14SwiftyEventBus0B12SubscriptionC7disposeyyF":{"name":"dispose()","abstract":"

Undocumented

","parent_name":"EventSubscription"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C7defaultACvpZ":{"name":"default","abstract":"

The default common EventBus instance

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C6domainSSvp":{"name":"domain","abstract":"

The domain string that identify different EventBus instance

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0CACSS6domain_tcfc":{"name":"init(domain:)","abstract":"

The construction of EventBus

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBus"},"Classes/EventBus.html":{"name":"EventBus","abstract":"

Undocumented

"},"Classes.html#/s:14SwiftyEventBus0B10SubscriberC":{"name":"EventSubscriber","abstract":"

Undocumented

"},"Classes/EventSubscription.html":{"name":"EventSubscription","abstract":"

Undocumented

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/EventBusSafety.html#/s:14SwiftyEventBus0bC6SafetyP4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBusSafety"},"Protocols/EventPresentable.html#/s:14SwiftyEventBus0B11PresentableP17processIdentifierSSvpZ":{"name":"processIdentifier","abstract":"

Undocumented

","parent_name":"EventPresentable"},"Protocols/EventBusSafePostable.html#/s:14SwiftyEventBus0bC12SafePostableP4postyqd__KAA0B11PresentableRd__lF":{"name":"post(_:)","abstract":"

Safe post a value to all subscriber,","parent_name":"EventBusSafePostable"},"Protocols/EventBusPostable.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","abstract":"

Post a value to all subsctiber

","parent_name":"EventBusPostable"},"Protocols/EventBusObservable.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","abstract":"

Register a message event for specify DataStruct

","parent_name":"EventBusObservable"},"Protocols/EventBusObservable.html":{"name":"EventBusObservable","abstract":"

Undocumented

"},"Protocols/EventBusPostable.html":{"name":"EventBusPostable","abstract":"

Undocumented

"},"Protocols/EventBusSafePostable.html":{"name":"EventBusSafePostable","abstract":"

Undocumented

"},"Protocols/EventPresentable.html":{"name":"EventPresentable","abstract":"

Undocumented

"},"Protocols/EventBusSafety.html":{"name":"EventBusSafety","abstract":"

Undocumented

"},"Extensions/Reactive.html#/s:14SwiftyEventBus8registerXeXeF":{"name":"register(_:)","abstract":"

Reactive wrapper for register(on:)

","parent_name":"Reactive"},"Extensions/EventBusMiddleWare.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","parent_name":"EventBusMiddleWare"},"Extensions/EventBusMiddleWare.html#/s:14SwiftyEventBus0bC10MiddleWareC4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBusMiddleWare"},"Extensions/EventBusDangerMiddleWare.html#/s:14SwiftyEventBus0bC12SafePostableP4postyqd__KAA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBusDangerMiddleWare"},"Extensions/EventBusPureMiddleWare.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBusPureMiddleWare"},"Extensions/EventBusPureMiddleWare.html":{"name":"EventBusPureMiddleWare","abstract":"

Undocumented

"},"Extensions/EventBusDangerMiddleWare.html":{"name":"EventBusDangerMiddleWare","abstract":"

Undocumented

"},"Extensions/EventBusMiddleWare.html":{"name":"EventBusMiddleWare","abstract":"

Undocumented

"},"Extensions/Reactive.html":{"name":"Reactive"},"Enums/DispatchMode.html#/s:14SwiftyEventBus12DispatchModeO4sameA2CmF":{"name":"same","abstract":"

Undocumented

","parent_name":"DispatchMode"},"Enums/DispatchMode.html#/s:14SwiftyEventBus12DispatchModeO4mainA2CmF":{"name":"main","abstract":"

Undocumented

","parent_name":"DispatchMode"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO5valueACSicACmF":{"name":"value","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO3lowACvpZ":{"name":"low","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO7defaultACvpZ":{"name":"default","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPriority.html#/s:14SwiftyEventBus0bC8PriorityO4highACvpZ":{"name":"high","abstract":"

Undocumented

","parent_name":"EventBusPriority"},"Enums/EventBusPostError.html#/s:14SwiftyEventBus0bC9PostErrorO7uselessA2CmF":{"name":"useless","abstract":"

Undocumented

","parent_name":"EventBusPostError"},"Enums/EventBusPostError.html":{"name":"EventBusPostError","abstract":"

The error for posting event

"},"Enums/EventBusPriority.html":{"name":"EventBusPriority","abstract":"

The priority of subscriber to revieve message

"},"Enums/DispatchMode.html":{"name":"DispatchMode","abstract":"

The subscribe model when code excuting

"},"Classes/EventSubscription.html#/s:14SwiftyEventBus0B12SubscriptionC7disposeyyF":{"name":"dispose()","abstract":"

Undocumented

","parent_name":"EventSubscription"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C7defaultACvpZ":{"name":"default","abstract":"

The default common EventBus instance

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C6domainSSvp":{"name":"domain","abstract":"

The domain string that identify different EventBus instance

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0CACSS6domain_tcfc":{"name":"init(domain:)","abstract":"

The construction of EventBus

","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC8PostableP4postyqd__AA0B11PresentableRd__lF":{"name":"post(_:)","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC10ObservableP8registerAA0B12SubscriptionCyqd__GAA12DispatchModeO2on_AA0bC8PriorityO8priorityyqd__c07messageB0tAA0B11PresentableRd__lF":{"name":"register(on:priority:messageEvent:)","parent_name":"EventBus"},"Classes/EventBus.html#/s:14SwiftyEventBus0bC0C4safeAA0bC12SafePostable_pvp":{"name":"safe","abstract":"

Undocumented

","parent_name":"EventBus"},"Classes/EventBus.html":{"name":"EventBus","abstract":"

Undocumented

"},"Classes.html#/s:14SwiftyEventBus0B10SubscriberC":{"name":"EventSubscriber","abstract":"

Undocumented

"},"Classes/EventSubscription.html":{"name":"EventSubscription","abstract":"

Undocumented

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/Enums/EventBusPostError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPostError Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPostError

102 |
103 |
104 |
public enum EventBusPostError : Error
105 | 106 |
107 |
108 |

The error for posting event

109 | 110 |
    111 |
  • useless: post a message that no subscriber observing
  • 112 |
113 | 114 |
115 |
116 |
117 |
    118 |
  • 119 |
    120 | 121 | 122 | 123 | useless 124 | 125 |
    126 |
    127 |
    128 |
    129 |
    130 |
    131 |

    Undocumented

    132 | 133 |
    134 |
    135 |

    Declaration

    136 |
    137 |

    Swift

    138 |
    case useless
    139 | 140 |
    141 |
    142 |
    143 |
    144 |
  • 145 |
146 |
147 |
148 |
149 | 153 |
154 |
155 | 156 |
157 | 158 | -------------------------------------------------------------------------------- /docs/Protocols/EventBusSafety.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusSafety Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusSafety

102 |
103 |
104 |
public protocol EventBusSafety
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | safe 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Undocumented

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    var safe: EventBusSafePostable { get }
    135 | 136 |
    137 |
    138 |
    139 |
    140 |
  • 141 |
142 |
143 |
144 |
145 | 149 |
150 |
151 | 152 |
153 | 154 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Enums/EventBusPostError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPostError Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPostError

102 |
103 |
104 |
public enum EventBusPostError : Error
105 | 106 |
107 |
108 |

The error for posting event

109 | 110 |
    111 |
  • useless: post a message that no subscriber observing
  • 112 |
113 | 114 |
115 |
116 |
117 |
    118 |
  • 119 |
    120 | 121 | 122 | 123 | useless 124 | 125 |
    126 |
    127 |
    128 |
    129 |
    130 |
    131 |

    Undocumented

    132 | 133 |
    134 |
    135 |

    Declaration

    136 |
    137 |

    Swift

    138 |
    case useless
    139 | 140 |
    141 |
    142 |
    143 |
    144 |
  • 145 |
146 |
147 |
148 |
149 | 153 |
154 |
155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /docs/Extensions/Reactive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Reactive Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

Reactive

102 | 103 |
104 |
105 |
106 |
    107 |
  • 108 |
    109 | 110 | 111 | 112 | register(_:) 113 | 114 |
    115 |
    116 |
    117 |
    118 |
    119 |
    120 |

    Reactive wrapper for register(on:)

    121 | 122 |
    123 |
    124 |

    Declaration

    125 |
    126 |

    Swift

    127 |
    public func register<T>(_ type: T.Type) -> Observable<T> where T : EventPresentable
    128 | 129 |
    130 |
    131 |
    132 |
    133 |
  • 134 |
135 |
136 |
137 |
138 | 142 |
143 |
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Protocols/EventBusSafety.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusSafety Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusSafety

102 |
103 |
104 |
public protocol EventBusSafety
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | safe 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Undocumented

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    var safe: EventBusSafePostable { get }
    135 | 136 |
    137 |
    138 |
    139 |
    140 |
  • 141 |
142 |
143 |
144 |
145 | 149 |
150 |
151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /docs/Classes/EventSubscription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventSubscription Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventSubscription

102 |
103 |
104 |
public class EventSubscription<T> where T : EventPresentable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | dispose() 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Undocumented

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    public func dispose()
    135 | 136 |
    137 |
    138 |
    139 |
    140 |
  • 141 |
142 |
143 |
144 |
145 | 149 |
150 |
151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Extensions/Reactive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Reactive Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

Reactive

102 | 103 |
104 |
105 |
106 |
    107 |
  • 108 |
    109 | 110 | 111 | 112 | register(_:) 113 | 114 |
    115 |
    116 |
    117 |
    118 |
    119 |
    120 |

    Reactive wrapper for register(on:)

    121 | 122 |
    123 |
    124 |

    Declaration

    125 |
    126 |

    Swift

    127 |
    public func register<T>(_ type: T.Type) -> Observable<T> where T : EventPresentable
    128 | 129 |
    130 |
    131 |
    132 |
    133 |
  • 134 |
135 |
136 |
137 |
138 | 142 |
143 |
144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Classes/EventSubscription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventSubscription Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventSubscription

102 |
103 |
104 |
public class EventSubscription<T> where T : EventPresentable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | dispose() 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Undocumented

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    public func dispose()
    135 | 136 |
    137 |
    138 |
    139 |
    140 |
  • 141 |
142 |
143 |
144 |
145 | 149 |
150 |
151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /docs/Extensions/EventBusPureMiddleWare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPureMiddleWare Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPureMiddleWare

102 |
103 |
104 |
class EventBusPureMiddleWare : EventBusMiddleWare
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 | 128 |
    129 |
    130 |

    Declaration

    131 |
    132 |

    Swift

    133 |
    public func post<T>(_ cargo: T) where T : EventPresentable
    134 | 135 |
    136 |
    137 |
    138 |
    139 |
  • 140 |
141 |
142 |
143 |
144 | 148 |
149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/Extensions/EventBusDangerMiddleWare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusDangerMiddleWare Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusDangerMiddleWare

102 |
103 |
104 |
class EventBusDangerMiddleWare : EventBusMiddleWare
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 | 128 |
    129 |
    130 |

    Declaration

    131 |
    132 |

    Swift

    133 |
    public func post<T>(_ cargo: T) throws where T : EventPresentable
    134 | 135 |
    136 |
    137 |
    138 |
    139 |
  • 140 |
141 |
142 |
143 |
144 | 148 |
149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/Protocols/EventPresentable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventPresentable Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventPresentable

102 |
103 |
104 |
public protocol EventPresentable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | processIdentifier 120 | 121 | 122 | Default implementation 123 | 124 |
    125 |
    126 |
    127 |
    128 |
    129 |
    130 |

    Undocumented

    131 | 132 |
    133 |

    Default Implementation

    134 |
    135 |

    Undocumented

    136 | 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    static var processIdentifier: String { get }
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
150 |
151 |
152 |
153 | 157 |
158 |
159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Extensions/EventBusPureMiddleWare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPureMiddleWare Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPureMiddleWare

102 |
103 |
104 |
class EventBusPureMiddleWare : EventBusMiddleWare
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 | 128 |
    129 |
    130 |

    Declaration

    131 |
    132 |

    Swift

    133 |
    public func post<T>(_ cargo: T) where T : EventPresentable
    134 | 135 |
    136 |
    137 |
    138 |
    139 |
  • 140 |
141 |
142 |
143 |
144 | 148 |
149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Extensions/EventBusDangerMiddleWare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusDangerMiddleWare Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusDangerMiddleWare

102 |
103 |
104 |
class EventBusDangerMiddleWare : EventBusMiddleWare
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 | 128 |
    129 |
    130 |

    Declaration

    131 |
    132 |

    Swift

    133 |
    public func post<T>(_ cargo: T) throws where T : EventPresentable
    134 | 135 |
    136 |
    137 |
    138 |
    139 |
  • 140 |
141 |
142 |
143 |
144 | 148 |
149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Protocols/EventPresentable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventPresentable Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventPresentable

102 |
103 |
104 |
public protocol EventPresentable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | processIdentifier 120 | 121 | 122 | Default implementation 123 | 124 |
    125 |
    126 |
    127 |
    128 |
    129 |
    130 |

    Undocumented

    131 | 132 |
    133 |

    Default Implementation

    134 |
    135 |

    Undocumented

    136 | 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    static var processIdentifier: String { get }
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
150 |
151 |
152 |
153 | 157 |
158 |
159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /docs/Protocols/EventBusPostable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPostable Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPostable

102 |
103 |
104 |
public protocol EventBusPostable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Post a value to all subsctiber

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    func post<T>(_ cargo: T) where T : EventPresentable
    135 | 136 |
    137 |
    138 |
    139 |

    Parameters

    140 | 141 | 142 | 143 | 148 | 153 | 154 | 155 |
    144 | 145 | cargo 146 | 147 | 149 |
    150 |

    The playload of any type

    151 |
    152 |
    156 |
    157 |
    158 |
    159 |
  • 160 |
161 |
162 |
163 |
164 | 168 |
169 |
170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /docs/docsets/SwiftyEventBus.docset/Contents/Resources/Documents/Protocols/EventBusPostable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusPostable Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusPostable

102 |
103 |
104 |
public protocol EventBusPostable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Post a value to all subsctiber

    128 | 129 |
    130 |
    131 |

    Declaration

    132 |
    133 |

    Swift

    134 |
    func post<T>(_ cargo: T) where T : EventPresentable
    135 | 136 |
    137 |
    138 |
    139 |

    Parameters

    140 | 141 | 142 | 143 | 148 | 153 | 154 | 155 |
    144 | 145 | cargo 146 | 147 | 149 |
    150 |

    The playload of any type

    151 |
    152 |
    156 |
    157 |
    158 |
    159 |
  • 160 |
161 |
162 |
163 |
164 | 168 |
169 |
170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /docs/css/jazzy.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td { 2 | background: transparent; 3 | border: 0; 4 | margin: 0; 5 | outline: 0; 6 | padding: 0; 7 | vertical-align: baseline; } 8 | 9 | body { 10 | background-color: #f2f2f2; 11 | font-family: Helvetica, freesans, Arial, sans-serif; 12 | font-size: 14px; 13 | -webkit-font-smoothing: subpixel-antialiased; 14 | word-wrap: break-word; } 15 | 16 | h1, h2, h3 { 17 | margin-top: 0.8em; 18 | margin-bottom: 0.3em; 19 | font-weight: 100; 20 | color: black; } 21 | 22 | h1 { 23 | font-size: 2.5em; } 24 | 25 | h2 { 26 | font-size: 2em; 27 | border-bottom: 1px solid #e2e2e2; } 28 | 29 | h4 { 30 | font-size: 13px; 31 | line-height: 1.5; 32 | margin-top: 21px; } 33 | 34 | h5 { 35 | font-size: 1.1em; } 36 | 37 | h6 { 38 | font-size: 1.1em; 39 | color: #777; } 40 | 41 | .section-name { 42 | color: gray; 43 | display: block; 44 | font-family: Helvetica; 45 | font-size: 22px; 46 | font-weight: 100; 47 | margin-bottom: 15px; } 48 | 49 | pre, code { 50 | font: 0.95em Menlo, monospace; 51 | color: #777; 52 | word-wrap: normal; } 53 | 54 | p code, li code { 55 | background-color: #eee; 56 | padding: 2px 4px; 57 | border-radius: 4px; } 58 | 59 | a { 60 | color: #0088cc; 61 | text-decoration: none; } 62 | 63 | ul { 64 | padding-left: 15px; } 65 | 66 | li { 67 | line-height: 1.8em; } 68 | 69 | img { 70 | max-width: 100%; } 71 | 72 | blockquote { 73 | margin-left: 0; 74 | padding: 0 10px; 75 | border-left: 4px solid #ccc; } 76 | 77 | .content-wrapper { 78 | margin: 0 auto; 79 | width: 980px; } 80 | 81 | header { 82 | font-size: 0.85em; 83 | line-height: 26px; 84 | background-color: #414141; 85 | position: fixed; 86 | width: 100%; 87 | z-index: 1; } 88 | header img { 89 | padding-right: 6px; 90 | vertical-align: -4px; 91 | height: 16px; } 92 | header a { 93 | color: #fff; } 94 | header p { 95 | float: left; 96 | color: #999; } 97 | header .header-right { 98 | float: right; 99 | margin-left: 16px; } 100 | 101 | #breadcrumbs { 102 | background-color: #f2f2f2; 103 | height: 27px; 104 | padding-top: 17px; 105 | position: fixed; 106 | width: 100%; 107 | z-index: 1; 108 | margin-top: 26px; } 109 | #breadcrumbs #carat { 110 | height: 10px; 111 | margin: 0 5px; } 112 | 113 | .sidebar { 114 | background-color: #f9f9f9; 115 | border: 1px solid #e2e2e2; 116 | overflow-y: auto; 117 | overflow-x: hidden; 118 | position: fixed; 119 | top: 70px; 120 | bottom: 0; 121 | width: 230px; 122 | word-wrap: normal; } 123 | 124 | .nav-groups { 125 | list-style-type: none; 126 | background: #fff; 127 | padding-left: 0; } 128 | 129 | .nav-group-name { 130 | border-bottom: 1px solid #e2e2e2; 131 | font-size: 1.1em; 132 | font-weight: 100; 133 | padding: 15px 0 15px 20px; } 134 | .nav-group-name > a { 135 | color: #333; } 136 | 137 | .nav-group-tasks { 138 | margin-top: 5px; } 139 | 140 | .nav-group-task { 141 | font-size: 0.9em; 142 | list-style-type: none; 143 | white-space: nowrap; } 144 | .nav-group-task a { 145 | color: #888; } 146 | 147 | .main-content { 148 | background-color: #fff; 149 | border: 1px solid #e2e2e2; 150 | margin-left: 246px; 151 | position: absolute; 152 | overflow: hidden; 153 | padding-bottom: 60px; 154 | top: 70px; 155 | width: 734px; } 156 | .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote { 157 | margin-bottom: 1em; } 158 | .main-content p { 159 | line-height: 1.8em; } 160 | .main-content section .section:first-child { 161 | margin-top: 0; 162 | padding-top: 0; } 163 | .main-content section .task-group-section .task-group:first-of-type { 164 | padding-top: 10px; } 165 | .main-content section .task-group-section .task-group:first-of-type .section-name { 166 | padding-top: 15px; } 167 | .main-content section .heading:before { 168 | content: ""; 169 | display: block; 170 | padding-top: 70px; 171 | margin: -70px 0 0; } 172 | 173 | .section { 174 | padding: 0 25px; } 175 | 176 | .highlight { 177 | background-color: #eee; 178 | padding: 10px 12px; 179 | border: 1px solid #e2e2e2; 180 | border-radius: 4px; 181 | overflow-x: auto; } 182 | 183 | .declaration .highlight { 184 | overflow-x: initial; 185 | padding: 0 40px 40px 0; 186 | margin-bottom: -25px; 187 | background-color: transparent; 188 | border: none; } 189 | 190 | .section-name { 191 | margin: 0; 192 | margin-left: 18px; } 193 | 194 | .task-group-section { 195 | padding-left: 6px; 196 | border-top: 1px solid #e2e2e2; } 197 | 198 | .task-group { 199 | padding-top: 0px; } 200 | 201 | .task-name-container a[name]:before { 202 | content: ""; 203 | display: block; 204 | padding-top: 70px; 205 | margin: -70px 0 0; } 206 | 207 | .item { 208 | padding-top: 8px; 209 | width: 100%; 210 | list-style-type: none; } 211 | .item a[name]:before { 212 | content: ""; 213 | display: block; 214 | padding-top: 70px; 215 | margin: -70px 0 0; } 216 | .item code { 217 | background-color: transparent; 218 | padding: 0; } 219 | .item .token { 220 | padding-left: 3px; 221 | margin-left: 15px; 222 | font-size: 11.9px; } 223 | .item .declaration-note { 224 | font-size: .85em; 225 | color: gray; 226 | font-style: italic; } 227 | 228 | .pointer-container { 229 | border-bottom: 1px solid #e2e2e2; 230 | left: -23px; 231 | padding-bottom: 13px; 232 | position: relative; 233 | width: 110%; } 234 | 235 | .pointer { 236 | background: #f9f9f9; 237 | border-left: 1px solid #e2e2e2; 238 | border-top: 1px solid #e2e2e2; 239 | height: 12px; 240 | left: 21px; 241 | top: -7px; 242 | -webkit-transform: rotate(45deg); 243 | -moz-transform: rotate(45deg); 244 | -o-transform: rotate(45deg); 245 | transform: rotate(45deg); 246 | position: absolute; 247 | width: 12px; } 248 | 249 | .height-container { 250 | display: none; 251 | left: -25px; 252 | padding: 0 25px; 253 | position: relative; 254 | width: 100%; 255 | overflow: hidden; } 256 | .height-container .section { 257 | background: #f9f9f9; 258 | border-bottom: 1px solid #e2e2e2; 259 | left: -25px; 260 | position: relative; 261 | width: 100%; 262 | padding-top: 10px; 263 | padding-bottom: 5px; } 264 | 265 | .aside, .language { 266 | padding: 6px 12px; 267 | margin: 12px 0; 268 | border-left: 5px solid #dddddd; 269 | overflow-y: hidden; } 270 | .aside .aside-title, .language .aside-title { 271 | font-size: 9px; 272 | letter-spacing: 2px; 273 | text-transform: uppercase; 274 | padding-bottom: 0; 275 | margin: 0; 276 | color: #aaa; 277 | -webkit-user-select: none; } 278 | .aside p:last-child, .language p:last-child { 279 | margin-bottom: 0; } 280 | 281 | .language { 282 | border-left: 5px solid #cde9f4; } 283 | .language .aside-title { 284 | color: #4b8afb; } 285 | 286 | .aside-warning { 287 | border-left: 5px solid #ff6666; } 288 | .aside-warning .aside-title { 289 | color: #ff0000; } 290 | 291 | .graybox { 292 | border-collapse: collapse; 293 | width: 100%; } 294 | .graybox p { 295 | margin: 0; 296 | word-break: break-word; 297 | min-width: 50px; } 298 | .graybox td { 299 | border: 1px solid #e2e2e2; 300 | padding: 5px 25px 5px 10px; 301 | vertical-align: middle; } 302 | .graybox tr td:first-of-type { 303 | text-align: right; 304 | padding: 7px; 305 | vertical-align: top; 306 | word-break: normal; 307 | width: 40px; } 308 | 309 | .slightly-smaller { 310 | font-size: 0.9em; } 311 | 312 | #footer { 313 | position: absolute; 314 | bottom: 10px; 315 | margin-left: 25px; } 316 | #footer p { 317 | margin: 0; 318 | color: #aaa; 319 | font-size: 0.8em; } 320 | 321 | html.dash header, html.dash #breadcrumbs, html.dash .sidebar { 322 | display: none; } 323 | html.dash .main-content { 324 | width: 980px; 325 | margin-left: 0; 326 | border: none; 327 | width: 100%; 328 | top: 0; 329 | padding-bottom: 0; } 330 | html.dash .height-container { 331 | display: block; } 332 | html.dash .item .token { 333 | margin-left: 0; } 334 | html.dash .content-wrapper { 335 | width: auto; } 336 | html.dash #footer { 337 | position: static; } 338 | -------------------------------------------------------------------------------- /docs/Protocols/EventBusSafePostable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EventBusSafePostable Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

SwiftyEventBus Docs (33% documented)

18 |

View on GitHub

19 |
20 |
21 |
22 | 27 |
28 |
29 | 98 |
99 |
100 |
101 |

EventBusSafePostable

102 |
103 |
104 |
public protocol EventBusSafePostable
105 | 106 |
107 |
108 |

Undocumented

109 | 110 |
111 |
112 |
113 |
    114 |
  • 115 |
    116 | 117 | 118 | 119 | post(_:) 120 | 121 |
    122 |
    123 |
    124 |
    125 |
    126 |
    127 |

    Safe post a value to all subscriber, 128 | make sure there is one subscriber at least

    129 | 130 |
    131 |
    132 |

    Declaration

    133 |
    134 |

    Swift

    135 |
    func post<T>(_ cargo: T) throws where T : EventPresentable
    136 | 137 |
    138 |
    139 |
    140 |

    Parameters

    141 | 142 | 143 | 144 | 149 | 154 | 155 | 156 |
    145 | 146 | cargo 147 | 148 | 150 |
    151 |

    The playload of any type

    152 |
    153 |
    157 |
    158 |
    159 |
    160 |
  • 161 |
162 |
163 |
164 |
165 | 169 |
170 |
171 | 172 | 173 | 174 | --------------------------------------------------------------------------------