Skip to content

Commit

Permalink
Add Subscribe MemoStream in DetailContents
Browse files Browse the repository at this point in the history
  • Loading branch information
JK0369 committed Apr 30, 2021
1 parent 3058fda commit 5bfe330
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions TodoList/DetailContents/DetailContentsInteractor.swift
Expand Up @@ -15,6 +15,7 @@ protocol DetailContentsRouting: ViewableRouting {
protocol DetailContentsPresentable: Presentable {
var listener: DetailContentsPresentableListener? { get set }
// TODO: Declare methods the interactor can invoke the presenter to present data.
func set(memo: Memo)
}

protocol DetailContentsListener: class {
Expand All @@ -37,6 +38,7 @@ final class DetailContentsInteractor: PresentableInteractor<DetailContentsPresen
override func didBecomeActive() {
super.didBecomeActive()
// TODO: Implement business logic here.
updateMemo()
}

override func willResignActive() {
Expand All @@ -48,4 +50,11 @@ final class DetailContentsInteractor: PresentableInteractor<DetailContentsPresen

private let memoStream: MemoStream

private func updateMemo() {
memoStream.memo
.subscribe(onNext: { [weak self] in
self?.presenter.set(memo: $0)
}).disposeOnDeactivate(interactor: self)
}

}
5 changes: 5 additions & 0 deletions TodoList/DetailContents/DetailContentsViewController.swift
Expand Up @@ -22,4 +22,9 @@ final class DetailContentsViewController: UIViewController, DetailContentsPresen
override func viewDidLoad() {
super.viewDidLoad()
}

func set(memo: Memo) {
print(memo)
}

}

0 comments on commit 5bfe330

Please sign in to comment.