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 | |
/// Command is a developer friendly wrapper around a closure | |
/// Every command always have Void result type, which do it less composable, | |
/// but also more focused | |
final class CommandWith<T> { | |
private let action: (T) -> () // underlying closure | |
// Block of `context` defined variables. Allows Command to be debugged | |
private let file: StaticString |
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
/// NOTE: based on the StackOverflow answer | |
/// https://stackoverflow.com/a/60107650/3527499 | |
import SwiftUI | |
struct TabBarView: View { | |
var items: [TabBarItem] | |
@State var selectedIndex = 0 | |
init(_ items: [TabBarItem]) { |
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
/// # UIKit basic implementation | |
open class UIScrollView : UIView, NSCoding, UIFocusItemScrollableContainer { | |
open var contentOffset: CGPoint // default CGPointZero | |
open var contentSize: CGSize // default CGSizeZero | |
open var contentInset: UIEdgeInsets // default UIEdgeInsetsZero. add additional scroll area around content | |
// all another code ... | |
} |
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 UserDetailsViewController: UIViewController { | |
// Define the public API ... | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
navigationController?.presentationController?.delegate = self | |
navigationItem.titleView = navigationTitleLabel | |
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 UserDetailsViewControllerDelegate: class { | |
func update(with user: User) | |
} | |
final class UserDetailsViewController: UIViewController { | |
var delegate: UserDetailsViewControllerDelegate? | |
// some code below ... | |
@IBAction func didTapContinueButton(_ sender: UIButton) { | |
let user = // get new instance of the User or use the existing one | |
delegate?.update(with: user) |
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 UIKit | |
import RxSwift | |
import RxCocoa | |
class AddDiscountTableViewCell: UITableViewCell { | |
@IBOutlet weak var discountTypeDropDown: SelectionDropDownView! | |
@IBOutlet weak var amountTextField: PrimaryTextField! | |
@IBOutlet weak var itemsDropDown: SelectionDropDownView! | |
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
#{Re-map default prefix: 'C-b' to 'C-a'} | |
unbind C-b | |
set -g prefix C-a | |
bind C-a send-prefix | |
### Main Options | |
########################################################################### | |
#{Scroll History} | |
set -g history-limit 50000 |
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
// MARK: - Throttler | |
public class Throttler { | |
private let queue: DispatchQueue = DispatchQueue.global(qos: .background) | |
private var job: DispatchWorkItem = DispatchWorkItem(block: {}) | |
private var previousRun: Date = Date.distantPast | |
private var maxInterval: Double | |
init(seconds: Double) { | |
self.maxInterval = seconds | |
} |
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 | |
/// One-parameter currying from two arguments function | |
typealias EscapingClosure<A, B> = (A) -> B | |
func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> EscapingClosure<A, (B) -> C> { | |
return { (a: A) -> ((_ b: B) -> C) in | |
return { (b: B) -> C in f(a, b) } | |
} | |
} |
NewerOlder