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 | |
| /// Debouncer is useful for situations like following. | |
| /// If we want to execute action n sec after the last trigger. | |
| public final class Debouncer<T> { | |
| let dispatchQueue: DispatchQueue | |
| let interval: TimeInterval | |
| let action: (T) -> Void | |
| private var _lastDispatchTime: DispatchTime? |
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
| class OperationGroup<T1, T2> { | |
| private var item1: T1? | |
| private var item2: T2? | |
| private var observers: [(T1, T2) -> Void] = [] | |
| func notify1(_ item: T1) { | |
| item1 = item | |
| _notifyIfNeeded() | |
| } | |
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
| // | |
| // PhotoLibraryChangeObserver.swift | |
| // ha1fAlbum | |
| // | |
| // Created by はるふ on 2018/10/29. | |
| // Copyright © 2018年 はるふ. All rights reserved. | |
| // | |
| import Photos | |
| import RxSwift |
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
| protocol Drinkable { | |
| } | |
| struct 🍶: Drinkable {} | |
| struct 🍺: Drinkable {} | |
| struct 🍸: Drinkable {} | |
| struct Person { | |
| } |
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 | |
| final class ThreadSafeCollection<T> { | |
| private let _lock = NSRecursiveLock() | |
| private var _observers: [Int: T] = [:] | |
| private var _nextKey = 0 | |
| func insert(_ observer: T) -> Int { | |
| _lock.lock() | |
| defer { |
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
| final class DeallocNotifier { | |
| private var _observers: [() -> Void] = [] | |
| func observe(_ observer: @escaping () -> Void) { | |
| _observers.append(observer) | |
| } | |
| deinit { | |
| _observers.forEach { observer in | |
| observer() |
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
| // | |
| // UserDefaultsStoreItem.swift | |
| // | |
| // Created by ha1f on 2019/02/26. | |
| // Copyright © 2019年 ha1f. All rights reserved. | |
| // | |
| import Foundation | |
| struct UserDefaultsStoreItem<T> { |
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
| // | |
| // KeyboardSizeObserver.swift | |
| // KeyboardFrameObserver | |
| // | |
| // Created by ha1f on 2019/02/08. | |
| // Copyright © ha1f 2019年 ha1f. All rights reserved. | |
| // | |
| 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
| // | |
| // CircleView.swift | |
| // | |
| // Created by ha1f on 2019/02/27. | |
| // Copyright © 2019年 ha1f. All rights reserved. | |
| // | |
| import UIKit | |
| /// I guess this is faster than using cornerRadius. |
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
| // | |
| // WithPrevious.swift | |
| // | |
| // Created by ha1f on 2018/06/25. | |
| // Copyright © 2018年 ha1f. All rights reserved. | |
| // | |
| import Foundation | |
| import RxCocoa | |
| import RxSwift |