Skip to content

Commit

Permalink
Opened necessary methods for overriding
Browse files Browse the repository at this point in the history
Annoying Library-use issues in Swift.
Methods which must be overridden or invoked from inheriting classes, where the base comes from a Library, must be marked `open` as `internal` become frustratingly inaccessible.
  • Loading branch information
LK-Simon committed Aug 15, 2022
1 parent 0f2de69 commit 8237d09
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ open class EventDispatcher: EventHandler, EventDispatching {
- Author: Simon J. Stuart
- Version: 1.0.0
*/
override internal func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
override open func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
let eventTypeName = String(reflecting: type(of: event))

var snapReceivers = [String:[ReceiverContainer]]()
Expand Down
2 changes: 1 addition & 1 deletion Sources/EventDrivenSwift/EventHandler/EventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ open class EventHandler: ObservableThread, EventHandling {
- Parameters:
- event: The Event to Process.
*/
internal func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
open func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
preconditionFailure("processEvent must be overriden!")
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/EventDrivenSwift/EventListener/EventListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class EventListener: EventHandler, EventListenable {
- dispatchMethod: The Means by which the Event was Dispatched
- priority: The Priority given to the Event at the point of Dispatch
*/
override internal func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
override open func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
let eventTypeName = String(reflecting: type(of: event))
var listeners: [EventListenerContainer]? = nil

Expand Down
2 changes: 1 addition & 1 deletion Sources/EventDrivenSwift/EventPool/EventPool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ open class EventPool<TEventThread: EventThreadable>: EventHandler, EventPooling
//TODO: Implement Scaling + Culling here
}

override internal func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
override open func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
let eventTypeName = String(reflecting: type(of: event))

var snapPools = [String:[ThreadContainer]]()
Expand Down
10 changes: 5 additions & 5 deletions Sources/EventDrivenSwift/EventThread/EventThread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ open class EventThread: EventReceiver, EventThreadable {
- Author: Simon J. Stuart
- Version: 4.0.0
*/
override internal func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
override open func processEvent(_ event: any Eventable, dispatchMethod: EventDispatchMethod, priority: EventPriority) {
let eventTypeName = String(reflecting: type(of: event))
var callback: EventCallback? = nil

Expand All @@ -53,7 +53,7 @@ open class EventThread: EventReceiver, EventThreadable {
- callback: The code to invoke for the given `Eventable` Type
- forEventType: The `Eventable` Type for which to Register the Callback
*/
internal func addEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEventType: Eventable.Type) {
open func addEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEventType: Eventable.Type) {
let eventTypeName = String(reflecting: forEventType)

_eventCallbacks.withLock { eventCallbacks in
Expand All @@ -76,7 +76,7 @@ open class EventThread: EventReceiver, EventThreadable {
- forEvent: The instance of the `Eventable` type to be processed
- priority: The `EventPriority` with which the `forEvent` was dispatched
*/
internal func callTypedEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEvent: Eventable, priority: EventPriority) {
open func callTypedEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEvent: Eventable, priority: EventPriority) {
if let typedEvent = forEvent as? TEvent {
callback(typedEvent, priority)
}
Expand All @@ -89,7 +89,7 @@ open class EventThread: EventReceiver, EventThreadable {
- Parameters:
- forEventType: The `Eventable` Type for which to Remove the Callback
*/
internal func removeEventCallback(forEventType: any Eventable) {
open func removeEventCallback(forEventType: any Eventable) {
let eventTypeName = String(reflecting: forEventType)

_eventCallbacks.withLock { eventCallbacks in
Expand All @@ -106,7 +106,7 @@ open class EventThread: EventReceiver, EventThreadable {
- Author: Simon J. Stuart
- Version: 4.0.0
*/
internal func registerEventListeners() {
open func registerEventListeners() {
// No default implementation
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/EventDrivenSwift/UIEventThread/UIEventThread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class UIEventThread: EventThread, UIEventThreadable {
}
}

override internal func callTypedEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEvent: Eventable, priority: EventPriority) {
override open func callTypedEventCallback<TEvent: Eventable>(_ callback: @escaping TypedEventCallback<TEvent>, forEvent: Eventable, priority: EventPriority) {
Task { /// Have to use a Task because this method is not `async`
await MainActor.run { /// Forces the call to be invoked on the `MainActor` (UI Thread)
super.callTypedEventCallback(callback, forEvent: forEvent, priority: priority)
Expand Down

0 comments on commit 8237d09

Please sign in to comment.