Skip to content

Instantly share code, notes, and snippets.

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] }
@AlexanderBollbach
AlexanderBollbach / gist:7ccf81c17465caa70a8c751e34853b25
Created June 20, 2020 01:43
a crazy over the top graph i made to model project types in my drawing app
//import UIKit
//import ComposableArchitecture
//
//enum RelationType: String, Hashable, Codable {
// case selected
// case child
// case soloed
//}
//
//protocol GraphType {
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)
//import Foundation
//import ComposableArchitecture
//
//protocol Selectable {
// var isSelected: Bool { get set }
//}
//
//
//protocol Creatable {
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 {
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”
enum GQLRequest {
case mutation(NonEmptySet<Mutation>)
case query(NonEmptySet<Query>)
enum Query {
case getCurrentUser(NonEmptySet<User>)
case currentUserPermissions(args: GQLRequestArgs.GetCurrentUserPermissions)
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])
const configuration: ConfigParams = {
appName: 'testApp',
configLocation: 'remote',
profile: 'dev',
configServerName: 'testApp',
logProperties: false,
interval: 60
};
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")