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 ComposableArchitecture | |
import FirebaseCore | |
import FirebaseAuth | |
import GoogleSignIn | |
struct FirebaseAuthClient { | |
var observeSignInState: () async -> AsyncStream<Bool> | |
} | |
extension FirebaseAuthClient { |
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 FirebaseFirestore | |
// MARK: - async | |
extension Query { | |
func addSnapshotListener<T>( | |
includeMetadataChanges: Bool = false | |
) -> AsyncThrowingStream<[T], Error> where T: Decodable{ | |
.init { continuation in | |
let listener = addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { result in |
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 FirebaseFirestore | |
@available(swift 5.0) | |
public extension Query { | |
func addSnapshotListener( | |
includeMetadataChanges: Bool = false, | |
listener: @escaping (Result<QuerySnapshot, Error>) -> () | |
) -> some ListenerRegistration { | |
addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { snapshot, error in | |
if let error { |
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
XCRUN = /usr/bin/env xcrun --sdk macosx | |
SWIFT_FORMAT_PATHS = <フォーマットしたいパス> | |
format: | |
$(XCRUN) swift run -c release \ | |
swift-format --mode format --recursive --in-place $(SWIFT_FORMAT_PATHS) | |
format-skip-build : | |
$(XCRUN) swift run -c release --skip-build \ | |
swift-format --mode format --recursive --in-place $(SWIFT_FORMAT_PATHS) |
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 FirebaseRemoteConfig | |
extension RemoteConfig { | |
func addOnConfigUpdateListener() -> AsyncThrowingStream<Set<String>, Error> { | |
.init { continuation in | |
addOnConfigUpdateListener { configUpdate, error in | |
if let error { | |
continuation.finish(throwing: error) | |
} else { |
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 FirebaseFirestore | |
import FirebaseFirestoreSwift | |
import Foundation | |
// MARK: - CollectionReference | |
public extension CollectionReference { | |
@discardableResult | |
func add<T: Encodable>( | |
_ value: T, |
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 | |
import FirebaseFirestore | |
import FirebaseFirestoreSwift | |
// MARK: - FirestoreClient | |
struct FirestoreClient { | |
enum Input { | |
enum Create { |
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 PhotosUI | |
class ViewController: UIViewController { | |
@IBAction func presentPickerForImagesIncludingLivePhotos(_ sender: Any) { | |
presentPicker(filter: PHPickerFilter.images) | |
} | |
private func presentPicker(filter: PHPickerFilter) { |
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 | |
var count = 0 | |
// 結果を保持させてすでに重複しているかを確認 | |
var set = Set<Int>() | |
for item in 0..<10000 { | |
let queue = DispatchQueue(label: "fuga") | |
// データ競合以前にそもそもここでエラーになることもある。 error: Execution was interrupted. | |
// The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. |
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
// https://www.avanderlee.com/swift/dependency-injection/ | |
// MARK: - Example | |
struct DataController { | |
@Injected(\.networkProvider) var networkProvider: NetworkProviding | |
func performDataRequest() { | |
networkProvider.requestData() | |
} |
NewerOlder