This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from MerrickSapsford/feature/prioritisation
Add prioritisation to listeners
- Loading branch information
Showing
8 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ListenerPriority.swift | ||
// Listenable | ||
// | ||
// Created by Merrick Sapsford on 19/01/2017. | ||
// Copyright © 2017 Merrick Sapsford. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Positional priority of a Listener within the enumeration queue. | ||
/// Ranges from 1 (low) to 1000 (high). | ||
/// | ||
/// - low: Listener is inserted at the end of the queue. (default) | ||
/// - high: Listener is inserted at the front of the queue. | ||
/// - custom: Custom queue prioritisation value (Range: 1 - 999) | ||
public enum ListenerPriority: Equatable { | ||
|
||
case low | ||
case high | ||
case custom(value: Int) | ||
|
||
internal var value: Int { | ||
get { | ||
switch self { | ||
case .high: | ||
return 1000 | ||
case .custom(let value): | ||
return value | ||
default: | ||
return 0 | ||
} | ||
} | ||
} | ||
|
||
public static func == (lhs: ListenerPriority, rhs: ListenerPriority) -> Bool { | ||
return lhs.value == rhs.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.