GTTexture-RxExtension 1.2.0

GTTexture-RxExtension 1.2.0

Maintained by Geektree0101.



 
Depends on:
RxSwift~> 4.0
RxCocoa~> 4.0
Texture~> 2.6
 

  • By
  • Geektree0101

alt text

CI Status Version License Platform

Concept

Texture provides various basic components such as ASTableNode, ASControlNode, ASButtonNode and so on.

ref: Node Subclasses

This library focused on ASControlNode to make convenience interactive wrappers on ASImageNode(UIImageView), ASNetworkImageNode(UIImageView), ASButtonNode and so on.

more see: Texture + RxSwift Interactive Wrapper

Example

Extension

ASBinder

: Subscribed Observer operates asynchronously.

Expectation Flow Expectation UI

But, Node dosen't know that event value applied on UI before draw.

Unexpectation Flow Unexpectation UI

In this case, Node should use setNeedsLayout. but, [bind:_] doesn't call setNeedsLayout automatically.

Normally, you can use like this code

// Profile NetworkImage Node is default
// username, description is Optional

// *** self is usernameNode supernode
viewModel.username
         .subscribe(onNext: { [weak self] text in 
            self?.usernameNode.rx.text(Node.usernameAttributes).onNext(text)
            self?.setNeedsLayout() // Here
         })
         .disposed(by: disposeBag)

If you use ASBinder then you don't need call setNeedsLayout. ASBinder will operates it automatically.

// Profile NetworkImage Node is default
// username, description is Optional

// *** self is usernameNode supernode
viewModel.username
         .bind(to: usernameNode.rx.text(Node.usernameAttributes),
               setNeedsLayout: self) 
         .disposed(by: disposeBag)

// *** self is descriptionNode supernode
viewModel.desc
         .bind(to: descriptionNode.rx.text(Node.descAttributes),
               setNeedsLayout: self) 
         .disposed(by: disposeBag)

If you don't need setNeedsLayout then just write code like this.

// setNeedsLayout default is nil!
viewModel.username
         .bind(to: usernameNode.rx.text(Node.usernameAttributes) 
         .disposed(by: disposeBag)

viewModel.desc
         .bind(to: descriptionNode.rx.text(Node.descAttributes)) 
         .disposed(by: disposeBag)
ASBinder Flow Output UI

Installation

GTTexture-RxExtension is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GTTexture-RxExtension'

Author

Geektree0101, [email protected]

License

GTTexture-RxExtension is available under the MIT license. See the LICENSE file for more info