Skip to content

Instantly share code, notes, and snippets.

View GeekTree0101's full-sized avatar
๐Ÿš€

David Ha (ๅฐๆฒณ) GeekTree0101

๐Ÿš€
View GitHub Profile
protocol MonkeyInteractorLogic: class {
var request: PublishRelay<MonkeyModel.Request> { get set }
}
class MonkeyInteractor: MonkeyInteractorLogic {
var presenter: MonkeyPresenterLogic? {
get {
@GeekTree0101
GeekTree0101 / RxVIP.swift
Last active May 25, 2019 14:50
RxVIP Interactor High Cohesion Issue Solve Example
struct MonkeyModel {
struct Request {
}
struct Response {
}
/*
Interactor์˜ input๊ณผ output์— ๋Œ€ํ•œ RxTest์ง„ํ–‰
์–ด๋– ํ•œ Request ์ด๋ฒคํŠธ ๋ฐœ์ƒ์‹œ ๊ธฐ๋Œ€ํ•˜๋Š” Response ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›๋Š”์ง€?
Worker๋Š” Stub์œผ๋กœ ์ƒ์„ฑํ•˜์—ฌ Interactor์— ์ฃผ์ž…
*/
class InteractorTests: XCTestCase {
var interactor: Interactor!
var disposeBag: DisposeBag!
class CellNode: ASCellNode {
let contentNode = ASDisplayNode()
override init() {
super.init()
self.ASM = true
self.contentNode.ASM = true
class Cell: ASCellNode {
let messageCountNode = ASButtonNode()
let likeCountNode = ASButtonNode()
func engageAreaLayoutSpec() -> ASLayoutSpec {
let stackLayout = ASStackLayoutSpec(children: [message....like])
return ASInsetLayoutSpec(insets: .init(top: 0, left: .inf, bottom: 0, right: 0, child: stackLayout)
}
}
@GeekTree0101
GeekTree0101 / AnimalInteractor.swift
Last active July 7, 2019 12:33
RxVIP inspired by Cycle.js Composable
protocol AnimalFeedInputLogics {
// ํ”ผ๋“œ ๋ฉ”์ปค๋‹ˆ์ฆ˜์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง๋งŒ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ทฐ์ปจ์œผ๋กœ ๋ถ€ํ„ฐ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›๋Š” ๋กœ์ง
var loadAnimalItem: PublishRelay<NextPage> { get } // Load more animation cell items
}
protocol AnimalCatCellInputLogics {
// ์˜ค์ง ๊ณ ์–‘์ด ์…€๋กœ ๋ถ€ํ„ฐ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›๋Š” ๋กœ์ง
var didTapFollow: PublishRelay<Int> { get } // Int: Cat identifier
}
@GeekTree0101
GeekTree0101 / RxCellNode.swift
Created July 7, 2019 12:55
Reactive CellNode
class ReactiveTestCellNode: ASCellNode {
public var viewState: ActionRelay<State> = .init()
func state() {
viewState.map { $0.title }
.distinguishUntilChanged()
.bind(to: titleNode.rx.title, setNeedsLayout: self)
.disposed(by: disposeBag)
}
class TestViewController {
let userInputView = InputView()
let displayOutputView: OutputView()
func bind() {
let state = Presenter.shared.state(type: OutputViewState.self, id: 1)
state.map { $0.title }.bind(to: displayOutputView.rx.title).disposed(by: bag)
}
}
@GeekTree0101
GeekTree0101 / DisplayCellNodeCASE_A.swift
Last active July 12, 2019 03:00
CleanSwift Example
class DisplayCellNode: ASCellNode {
// UI
let buttonNode = ASButtonNode()
// Props
weak var interactor: InteractorLogics!
private var presenter: DisplayCellPresenter = .init()
override func didLoad() {
@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()
}