SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DisplayCellNode: ASCellNode {
  2.  
  3.   // UI
  4.   let buttonNode = ASButtonNode()
  5.  
  6.   // Props
  7.   weak var interactor: InteractorLogics!
  8.   private var presenter: DisplayCellPresenter = .init()
  9.  
  10.   override func didLoad() {
  11.     super.didLoad()
  12.     buttonNode.addTarget(self, didTapButton:, .touchUpInside)
  13.   }
  14.  
  15.   @objc func didTapButton() {
  16.     // Request -> Response
  17.     let response = interactor.didTapButton(id: "user-12345")
  18.    
  19.     // Response -> ViewModel
  20.     let viewModel = response
  21.         .then { [weak self] user in
  22.           return self?.username(user: user) ?? brokenPromise()
  23.         }
  24.         .recover { [weak self] error in
  25.           return self?.errorMessage(error: error) ?? brokenPromise()
  26.         }
  27.    
  28.    // ViewModel -> Rendering
  29.    viewModel
  30.         .done { [weak self] username in
  31.             self?.buttonNode.text = username
  32.             self?.setNeedsLayout()
  33.         }
  34.   }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top