This file contains hidden or 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
/* | |
Ever try to user TaskGroups for working on a bunch of values in a collection concurrently? | |
It's fine but was having issues if I wantd to limit work to only "n" current tasks at a time. | |
Throttling is available in AsyncAlgoriths, but that is time based, not number of tasks. | |
Also tried keeping a counter/window type data struct. | |
But found a cleaner way with `.async.buffer(policy: .bounded(maxConcurrentTaskCount))` | |
NOTE: Your collection order will be lost, use a tuple with index to keep that information if you need it |
This file contains hidden or 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
// Using `.updating(...)` with a @GestureState seemed like the way to go | |
// but pressing state end update is not readily available | |
// standard `.onLongPress` modifier works best | |
struct LongPressExample: View { | |
let duration: TimeInterval | |
@State private var progress: CGFloat = 0 | |
@State private var isDone = false | |
var body: some View { |
This file contains hidden or 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 SwiftUI | |
import Combine | |
#if os(iOS) | |
import UIKit.UIResponder | |
#endif | |
class KeyboardObserver: ObservableObject { | |
struct State: Equatable { | |
let frame: CGRect | |
let isLocal: Bool // on multitasking iPad apps, all visible apps notified |
This file contains hidden or 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 Combine | |
fileprivate class CancellableStore { | |
static let shared = CancellableStore() | |
var cancellables = Set<AnyCancellable>() | |
} | |
public enum DownloadOutput { | |
case complete(Data) |
This file contains hidden or 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 Combine | |
var count = 0 | |
enum Marker: CustomDebugStringConvertible { | |
case A(Int) | |
case B(Int) | |
var debugDescription: String { |
This file contains hidden or 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
//------------------------------------------------------------------------ | |
// The SwiftUI Lab: Advanced SwiftUI Animations | |
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
//------------------------------------------------------------------------ | |
import SwiftUI | |
struct ContentView: View { | |
This file contains hidden or 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
// | |
// EnvironmentVariables.swift | |
// PlaylogR | |
// | |
// Created by Cenk Bilgen on 2019-10-12. | |
// Copyright © 2019 Cenk Bilgen. All rights reserved. | |
// | |
import SwiftUI | |
import UIKit |
This file contains hidden or 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
// | |
// OriginAxis.swift | |
// | |
// Created by abc on 2019-03-07. | |
// Copyright © 2019 Cenk Bilgen. All rights reserved. | |
// | |
import Foundation | |
import SceneKit |
This file contains hidden or 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
// | |
// URLRequestExtension.swift | |
// | |
// Created by Cenk Bilgen on 2019-01-30. | |
// Copyright © 2019 abc. All rights reserved. | |
// | |
import Foundation | |
extension URLRequest { |
This file contains hidden or 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
// | |
// GraphQL.swift | |
// | |
// Created by Cenk Bilgen on 2018-10-15. | |
// Copyright © 2018 Cenk Bilgen. All rights reserved. | |
// | |
import Foundation | |
// Generate a simple GraphQL search based query |