Skip to content

Instantly share code, notes, and snippets.

View GeekTree0101's full-sized avatar
💰

David Ha (小河) GeekTree0101

💰
View GitHub Profile
@GeekTree0101
GeekTree0101 / ASLayoutElememt+Extension.swift
Last active December 26, 2019 05:02
LayoutSpecBuildable.swift
extension ASLayoutElementStyle {
@discardableResult
func shrink(value: CGFloat = 1.0) -> Self {
self.flexShrink = value
return self
}
@discardableResult
@GeekTree0101
GeekTree0101 / leah.swift
Last active December 19, 2019 02:47
leah
struct A {
let p: Value?
let b: Value
}
_ = A(p: nil, b: Value())
sturct A {
@GeekTree0101
GeekTree0101 / UIView+TLLayout.h
Created November 21, 2019 01:17 — forked from ericcj/UIView+TLLayout.h
crazy that hiding a uiview doesn't affect its autolayout constraints. here's a category for the rest of the world who uses dynamic interfaces
#import <UIKit/UIKit.h>
@interface UIView (TLLayout)
@property (nonatomic, strong) NSArray *hiddenConstraints;
// set hidden and remove any constraints involving this view from its superview
- (void)hideAndRemoveConstraints;
- (void)showAndRestoreConstraints;
@GeekTree0101
GeekTree0101 / slack.go
Created August 12, 2019 00:22
Golang Slack Model
// SlackMessage is SlackMessage object
type SlackMessage struct {
Type string `json:"response_type"` // key: type default: in_channel
Text string `json:"text"`
Attatchments []SlackMessageAttachment `json:"attachments"`
}
// SlackMessageAttachment is SlackMessage attachment object
type SlackMessageAttachment struct {
@GeekTree0101
GeekTree0101 / 1viewModel.swift
Last active August 6, 2019 00:50
상태기반 ViewModel 과 Repository & DataSource 활용.
import RxSwift
import RxCocoa
// MARK: - Action
extension Reactive where Base: TestViewModel {
var refresh: Binder<Void> {
return Binder(base) { viewModel, _ in
guard let id = viewModel.viewState.value?.id else { return }
@GeekTree0101
GeekTree0101 / PromiseRepository.swift
Last active July 30, 2019 15:19
PromiseRepository
protocol DataPassing: class {
associatedtype DataSource
var dataSource: DataSource { get set }
}
protocol PromiseRepository: DataPassing {
func syncCache(_ promise: Promise<DataSource>) -> Promise<DataSource>
}
@GeekTree0101
GeekTree0101 / Repository.swift
Last active July 30, 2019 14:04
Repository Example
import RxSwift
import RxCocoa
class Repository {
private let remoteDataSource: RemoteDataSource
private let localDataSource: LocalDataSource
private let errorRelay = PublishRelay<Error?>()
class CellNode {
struct State {
var id: Int
var title: String?
var isLike: Bool
}
public var state: State?
weak var action: Action?
@GeekTree0101
GeekTree0101 / User.swift
Last active July 12, 2019 15:06
Model - View - Intention (MVI)
struct User {
var id: String
var username: String
}
extension User: ServiceLogics {
static func loadUser(id: String) -> Promise<User> { ... }
static func loadUserFromDB(id: String) -> Promise<User> { ... }
@GeekTree0101
GeekTree0101 / MVVM.swift
Last active July 12, 2019 02:40
Marty MVVM
class GlobalHook {
static let shared = GlobalHook()
var updateModel = PublishRelay<Model>()
}
protcol ViewModelProcotol {
func hook()
}