GithubHelp home page GithubHelp logo

neveragain11 / rxcocoa-texture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rxswiftcommunity/rxcocoa-texture

0.0 0.0 0.0 2.25 MB

RxCocoa Extension Library for Texture.

License: MIT License

Swift 98.74% Ruby 1.26%

rxcocoa-texture's Introduction

alt text

CI Status Version License Platform

Notice

pod 'RxCocoa-Texture', '3.x.x'

Your Contributions always welcome welcome!.

Concept

RxCocoa provides extensions to the Cocoa and Cocoa Touch frameworks to take advantage of RxSwift. Texture provides various basic UI components such as ASTableNode, ASControlNode, ASButtonNode and so on. ref: Node Subclasses

So, This Library provides extensions to the Texture frameworks to take advantage of RxSwift like a RxCocoa

ref: 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

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

swift 4.x

pod 'RxCocoa-Texture'

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. TextureGroup/Texture#977

Author

Geektree0101, [email protected]

License

This library belongs to RxSwiftCommunity. RxCocoa-Texture is available under the MIT license. See the LICENSE file for more info

rxcocoa-texture's People

Contributors

geektree0101 avatar ohkanghoon avatar innocarpe avatar neveragain11 avatar magi82 avatar kirillsh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.