https://github.com/geektree0101/gttexture-rxextension
Texture RxSwift Interactive Wrapper base on ASControlNode
https://github.com/geektree0101/gttexture-rxextension
asyncdisplaykit ios rxswift swift texture
Last synced: 10 months ago
JSON representation
Texture RxSwift Interactive Wrapper base on ASControlNode
- Host: GitHub
- URL: https://github.com/geektree0101/gttexture-rxextension
- Owner: GeekTree0101
- License: mit
- Created: 2018-05-05T04:29:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-02T10:56:49.000Z (almost 8 years ago)
- Last Synced: 2025-06-30T01:18:39.763Z (12 months ago)
- Topics: asyncdisplaykit, ios, rxswift, swift, texture
- Language: Swift
- Homepage:
- Size: 2.01 MB
- Stars: 11
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://travis-ci.org/GeekTree0101/GTTexture-RxExtension)
[](https://cocoapods.org/pods/GTTexture-RxExtension)
[](https://cocoapods.org/pods/GTTexture-RxExtension)
[](https://cocoapods.org/pods/GTTexture-RxExtension)
## Notice
### GTTexture+RxExtension will replace name as RxCocoa+Texture
### HERE -> https://github.com/GeekTree0101/RxCocoa-Texture
## Concept
Texture provides various basic components such as ASTableNode, ASControlNode, ASButtonNode and so on.
ref: [Node Subclasses](http://texturegroup.org/docs/node-overview.html)
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](https://medium.com/@h2s1880/texture-rxswift-interactive-wrapper-d3c9843ed8d7)
## Example
#### Extension
- [ASButtonNode RxExtension Example](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/Nodes/ButtonTestNode.swift)
- [ASImageNode RxExtension Example](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/Nodes/ImageTestNode.swift)
- [ASNetworkImageNode RxExtension Example](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/Nodes/NetworkImageTestNode.swift)
- [ASTextNode RxExtension Example](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/Nodes/TextTestNode.swift)
- [ASEditableTextNode RxExtension Example](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/Nodes/EditableTextTestNode.swift)
- [ASScrollNode](https://github.com/ReactiveX/RxSwift/blob/master/RxCocoa/iOS/UIScrollView%2BRx.swift)
#### 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
```swift
// 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.
```swift
// 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.
```swift
// 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
- [ASBinder](https://github.com/GeekTree0101/GTTexture-RxExtension/blob/master/Example/GTTexture-RxExtension/ASBinderTestNode.swift)
## Installation
GTTexture-RxExtension is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
#### swift 4.x
```ruby
pod 'GTTexture-RxExtension'
```
#### [DEPRECATED] swift 3.x
```ruby
pod 'GTTexture-RxExtension', '1.2.0-swift3.x'
```
## Caution
This library has been migrated to Texture 2.7.
When Rx subscribe logic moves from initialization to didLoad method. I no longer faced this problem.
When using RxSwift / RxCocoa, it is safe to subscribe from the didLoad method.
https://github.com/TextureGroup/Texture/issues/977
## Author
Geektree0101, h2s1880@gmail.com
## License
GTTexture-RxExtension is available under the MIT license. See the LICENSE file for more info