-
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.
Merge pull request #1 from riiid/feature/AddComposableArchitecture
Move to ComposableLogsSheetKit
- Loading branch information
Showing
11 changed files
with
365 additions
and
194 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
.swiftpm/xcode/xcshareddata/xcschemes/ComposableLogsSheetKit.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,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1400" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "ComposableLogsSheetKit" | ||
BuildableName = "ComposableLogsSheetKit" | ||
BlueprintName = "ComposableLogsSheetKit" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "ComposableLogsSheetKitTests" | ||
BuildableName = "ComposableLogsSheetKitTests" | ||
BlueprintName = "ComposableLogsSheetKitTests" | ||
ReferencedContainer = "container:"> | ||
</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 = "ComposableLogsSheetKitTests" | ||
BuildableName = "ComposableLogsSheetKitTests" | ||
BlueprintName = "ComposableLogsSheetKitTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</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"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "ComposableLogsSheetKit" | ||
BuildableName = "ComposableLogsSheetKit" | ||
BlueprintName = "ComposableLogsSheetKit" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
77 changes: 77 additions & 0 deletions
77
.swiftpm/xcode/xcshareddata/xcschemes/ComposableLogsSheetKitTests.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,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1400" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "ComposableLogsSheetKitTests" | ||
BuildableName = "ComposableLogsSheetKitTests" | ||
BlueprintName = "ComposableLogsSheetKitTests" | ||
ReferencedContainer = "container:"> | ||
</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 = "ComposableLogsSheetKitTests" | ||
BuildableName = "ComposableLogsSheetKitTests" | ||
BlueprintName = "ComposableLogsSheetKitTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</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"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "ComposableLogsSheetKitTests" | ||
BuildableName = "ComposableLogsSheetKitTests" | ||
BlueprintName = "ComposableLogsSheetKitTests" | ||
ReferencedContainer = "container:"> | ||
</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 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
40 changes: 40 additions & 0 deletions
40
Sources/ComposableLogsSheetKit/Extensions/TCA/Reducer+Log.swift
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,40 @@ | ||
// | ||
// Reducer+Log.swift | ||
// | ||
// | ||
// Created by Yessen Yermukhanbet on 2022/10/05. | ||
// Copyright © 2022 Riiid Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ComposableArchitecture | ||
|
||
extension Reducer where State: LoggableState { | ||
/// Saves each action run through the reducer as the log message if debug build configuration is on | ||
/// - Parameters: | ||
/// - isDebug: is debug configuration on | ||
public func log(isDebug: Bool) -> Self { | ||
.init { state, action, environment in | ||
if isDebug { | ||
state.logs.append(.init(message: "\(action)")) | ||
} | ||
return self.run(&state, action, environment) | ||
} | ||
} | ||
|
||
/// Saves the custom log message if debug build configuration is on | ||
/// - Parameters: | ||
/// - isDebug: is debug configuration on | ||
/// - message: custom log message | ||
public func log( | ||
isDebug: Bool, | ||
with message: @escaping ((Action) -> String) | ||
) -> Self { | ||
.init { state, action, environment in | ||
if isDebug { | ||
state.logs.append(.init(message: message(action))) | ||
} | ||
return self.run(&state, action, environment) | ||
} | ||
} | ||
} |
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,30 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Yessen Yermukhanbet on 2022/10/05. | ||
// Copyright © 2022 Riiid Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import LogsSheetKit | ||
|
||
public protocol LoggableState: Equatable { | ||
var logs: [ActionLog] { get set } | ||
} | ||
|
||
extension LoggableState { | ||
var logs: [ActionLog] { | ||
get { | ||
return GlobalLogs.shared.logs | ||
} | ||
set { | ||
GlobalLogs.shared.logs = newValue | ||
} | ||
} | ||
} | ||
|
||
struct GlobalLogs { | ||
static var shared: GlobalLogs = GlobalLogs() | ||
var logs: [ActionLog] = [] | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.