-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
385 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
build/ | ||
DerivedData/ | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
|
||
## Other | ||
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output |
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,13 @@ | ||
language: objective-c | ||
osx_image: xcode9.3 | ||
env: | ||
global: | ||
- PROJECT=Excitation.xcodeproj | ||
- SCHEME=Excitation | ||
- SDK=iphonesimulator | ||
- DEST="OS=11.3,name=iPhone 8" | ||
- CONFIG=Release | ||
script: | ||
- set -o pipefail | ||
- open -b com.apple.iphonesimulator # Workaround https://github.com/travis-ci/travis-ci/issues/3040 | ||
- xcodebuild test -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DEST" -configuration "$CONFIG" ENABLE_TESTABILITY=YES | xcpretty |
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
99 changes: 99 additions & 0 deletions
99
Excitation.xcodeproj/xcshareddata/xcschemes/Excitation.xcscheme
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,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "0930" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A132129F20A2344B001AE0D1" | ||
BuildableName = "Excitation.framework" | ||
BlueprintName = "Excitation" | ||
ReferencedContainer = "container:Excitation.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A13212A820A2344B001AE0D1" | ||
BuildableName = "ExcitationTests.xctest" | ||
BlueprintName = "ExcitationTests" | ||
ReferencedContainer = "container:Excitation.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A132129F20A2344B001AE0D1" | ||
BuildableName = "Excitation.framework" | ||
BlueprintName = "Excitation" | ||
ReferencedContainer = "container:Excitation.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A132129F20A2344B001AE0D1" | ||
BuildableName = "Excitation.framework" | ||
BlueprintName = "Excitation" | ||
ReferencedContainer = "container:Excitation.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A132129F20A2344B001AE0D1" | ||
BuildableName = "Excitation.framework" | ||
BlueprintName = "Excitation" | ||
ReferencedContainer = "container:Excitation.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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 was deleted.
Oops, something went wrong.
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,61 @@ | ||
import Foundation | ||
|
||
// Swift type inference bug workaround | ||
// ==================================================== | ||
// As of Swift 4.1 the compiler cannot differenciate between: | ||
// (T) -> Void where T is Void and Void -> Void. | ||
// | ||
// In the case where we need to create an Event that does not | ||
// carry data, use Emitter<None>() | ||
// | ||
public enum None { | ||
case None | ||
} | ||
|
||
public class Observer<T> { | ||
var f: ((T)->Void)? | ||
init(_ f: @escaping (T)->Void) { | ||
self.f = f | ||
} | ||
|
||
@objc func invoke(n: Notification) { | ||
if let payload = n.userInfo { | ||
f!(payload[0]! as! T) | ||
} else if self is Observer<None> { | ||
f!(None.None as! T) | ||
} else { | ||
let t = type(of: T.self) | ||
print("Excitation: Unexpected event from Emitter<\(t)> with no data.") | ||
} | ||
} | ||
} | ||
|
||
public class Emitter<T> { | ||
let nc = NotificationCenter() | ||
let nn = Notification.Name("ExcitationEvent") | ||
var obRef = [ObjectIdentifier: Observer<T>]() | ||
|
||
public func emit() { | ||
nc.post(name: nn, object: nil) | ||
} | ||
public func emit(_ data: T) { | ||
nc.post(name: nn, object: nil, userInfo: [0: data]) | ||
} | ||
|
||
public func observe(_ f: @escaping ()->Void) -> Observer<T> { | ||
return self.observe({ (_: T) in f() }) | ||
} | ||
public func observe(_ f: @escaping (T)->Void) -> Observer<T> { | ||
let ob = Observer<T>(f) | ||
nc.addObserver( | ||
ob, selector: #selector(ob.invoke(n:)), | ||
name: nn, object: nil) | ||
obRef[ObjectIdentifier(ob)] = ob | ||
return ob | ||
} | ||
|
||
public func remove(_ ob: Observer<T>) { | ||
nc.removeObserver(ob, name: nn, object: nil) | ||
obRef.removeValue(forKey: ObjectIdentifier(ob)) | ||
} | ||
} |
Oops, something went wrong.