GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RxSwiftCommunity/NSObject-Rx: Handy RxSwift extensions on NSObject, including rx.disposeBag.

BranchesTags
Open more actions menu

Latest commit

 

History

249 Commits
249 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
Demo
Demo
 
 
NSObject-Rx.xcodeproj
NSObject-Rx.xcodeproj
 
 
assets
assets
 
 
fastlane
fastlane
 
 
.gitignore
.gitignore
 
 
Cartfile
Cartfile
 
 
Cartfile.resolved
Cartfile.resolved
 
 
Changelog.md
Changelog.md
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
HasDisposeBag.swift
HasDisposeBag.swift
 
 
Info.plist
Info.plist
 
 
LICENSE
LICENSE
 
 
NSObject+Rx.podspec
NSObject+Rx.podspec
 
 
NSObject+Rx.swift
NSObject+Rx.swift
 
 
Package.resolved
Package.resolved
 
 
Package.swift
Package.swift
 
 
Readme.md
Readme.md
 
 
deploy.sh
deploy.sh
 
 

Repository files navigation

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.

About

Handy RxSwift extensions on NSObject, including rx.disposeBag.

Resources

Readme
MIT license
Activity
Custom properties

Stars

644 stars

Watchers

25 watching

Forks

64 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.