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
extension Reducer { | |
func gatherSignals<GlobalState, GlobalAction, GlobalEnvironment, Signal>( | |
signalLocations: [WritableKeyPath<GlobalState, Signal?>], | |
target: WritableKeyPath<GlobalState, [Signal]>, | |
startAction: GlobalAction | |
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment> { | |
.init { state, action, environment in | |
let signals = signalLocations.compactMap { state[keyPath: $0] } |
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
//import UIKit | |
//import ComposableArchitecture | |
// | |
//enum RelationType: String, Hashable, Codable { | |
// case selected | |
// case child | |
// case soloed | |
//} | |
// | |
//protocol GraphType { |
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
struct ContentView: View { | |
let content = ["long word","b","an even longer sentence to display"] | |
var body: some View { | |
ScrollView(.horizontal) { | |
HStack { | |
ForEach(Array(content.enumerated()), id: \.offset) { e in | |
Text(e.element).frame(maxWidth: .infinity) | |
} | |
.background(Color.yellow) |
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
//import Foundation | |
//import ComposableArchitecture | |
// | |
//protocol Selectable { | |
// var isSelected: Bool { get set } | |
//} | |
// | |
// | |
//protocol Creatable { |
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
extension ViewStore where State == SomeState, Action == SomeAction { | |
var displayValue: String { | |
// do a bunch of querying on viewStore | |
return "" | |
} | |
func sendAction(with id: Int) -> Void { | |
// create a | |
if viewStore.isValid { |
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
pointfree.co question: 'ListAction'? | |
I have been working on an app that has a very complex GUI. Think of a digital synth plugin where there are many levels of | |
nesting components (faders in envelope banks in presets of a project, etc.). One pattern I observed was that at each level | |
in the hierarchy I have to operate over some generic ‘element’ as well as manipulate the elements as a group. For this I | |
defined a ‘ListAction’. It looks roughly like the following: | |
enum ListAction<Element, ElementAction, ID> { | |
// … “List level actions” |
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
enum GQLRequest { | |
case mutation(NonEmptySet<Mutation>) | |
case query(NonEmptySet<Query>) | |
enum Query { | |
case getCurrentUser(NonEmptySet<User>) | |
case currentUserPermissions(args: GQLRequestArgs.GetCurrentUserPermissions) |
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
protocol APIType { | |
var currentEnvironment: API.RemoteEnv { get } | |
func update(environment: API.RemoteEnv) | |
@discardableResult func perform<T>(_ request: T, complete: @escaping (APIResult<T>) -> Void) -> Cancellable | |
} | |
class API: APIType { | |
struct Configuration { | |
typealias AuthenticationHeaders = (() -> [String: String]) |
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
const configuration: ConfigParams = { | |
appName: 'testApp', | |
configLocation: 'remote', | |
profile: 'dev', | |
configServerName: 'testApp', | |
logProperties: false, | |
interval: 60 | |
}; | |
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
private func getHttpLog(request: HTTPRequest) -> String { | |
var result: [String] = [] | |
result.append("==headers==") | |
request.headers.forEach { header in | |
result.append("key: \(header.key), value: \(header.value)") | |
} | |
result.append("==body==") | |
result.append(request.body?.string ?? "problem parsing body") | |
return result.joined(separator: "\n") |
NewerOlder