Giter Site home page Giter Site logo

tomisacat / nsobject-rx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rxswiftcommunity/nsobject-rx

0.0 0.0 0.0 1.13 MB

Handy RxSwift extensions on NSObject, including rx.disposeBag.

License: MIT License

Swift 62.00% Ruby 37.10% Shell 0.90%

nsobject-rx's Introduction

CircleCI

NSObject+Rx

If you're using RxSwift, you've probably encountered the following code more than a few times.

class MyObject: Whatever {
	let disposeBag = DisposeBag()

	...
}

You're actually not the only one; it has been typed many, many times.

Search screenshot showing many, many results.

Instead of adding a new property to every object, use this library to add it for you, to any subclass of NSObject.

thing
  .bind(to: otherThing)
  .disposed(by: rx.disposeBag)

Sweet.

It'll work just like a property: when the instance is deinit'd, the DisposeBag gets disposed. It's also a read/write property, so you can use your own, too.

If you want to add a DisposeBag to an Object that does not inherit from NSObject, you can also implement the protocol HasDisposeBag, and you're good to go. This protocol provides a default DisposeBag called disposeBag.

Installing

CocoaPods

Add to your Podfile:

pod 'NSObject+Rx'

And that'll be ๐Ÿ‘Œ

Carthage

Add to Cartfile:

github "RxSwiftCommunity/NSObject-Rx"

Add frameworks to your project (no need to "copy items if needed")

Run carthage update or carthage update --platform ios if you target iOS only

Add run script build phase /usr/local/bin/carthage copy-frameworks with input files being:

$(SRCROOT)/Carthage/Build/iOS/RxSwift.framework
$(SRCROOT)/Carthage/Build/iOS/NSObject_Rx.framework

And rule โœŒ๏ธ

Contributing

Source files are in the root directory. We use CocoaPods to develop, check out the unit tests in the Demo project.

License

MIT obvs.

Tim Cook dancing to the sound of a permissive license.

nsobject-rx's People

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.