Extensions that allow you to work with optionals

Related tags

Utility RxOptionals
Overview

RxOptionals

Sometimes it happens that you need to bind to several optional binders or to an optional method (for example, when using weak). To do this, we can resort to large constructs with guard, if, weak capturing and others.

weak var someController: SomeController?

func bind() {
    guard let binder = someController?.someView.rx.someBinder else { /*...*/ }
    someObservable.bind(to: binder).disposed(by: bag)
}

The guard construction looks a bit messy and it would be great to remove it (and put inside called function).

weak var someController: SomeController?

func bind() {
    someObservable.bind(to: someController?.someView.rx.someBinder).disposed(by: bag)
}

It may seem that not so much changes and that the code is getting longer, but after a while you will realize that you saved a lot of time and space, and were able to write cleaner and more functional code (because optionals were created for this) ;)

Installation

CocoaPods

You could install package via CocoaPods:
Add this line to your Podfile:

pod 'RxOptionals', :git => 'https://github.com/danyaffff/RxOptionals'

Swift Package manager

You could install package via Swift Package manager:

  1. In Xcode, open your project and navigate to File β†’ Swift Packages β†’ Add Package Dependency...
  2. Paste the repository URL (https://github.com/danyaffff/RxOptionals) and click Next.
  3. For Rules, select Branch (and set main branch) and click Next.
  4. Add library to desired Target and click Finish.
You might also like...
Helpful extensions for iOS app development πŸš€
Helpful extensions for iOS app development πŸš€

ExtensionKit includes many extensions, from getting the user location with a deterministic Combine API to a shimmer loading animation, to keyboard notification updates, bottom sheet and much much more. Check out the docs below or install the library with SPM to try it out.

 Extendy - A set of useful string extensions.
Extendy - A set of useful string extensions.

Extendy A set of useful string extensions. Requirements iOS 11.0+ Swift 5+ Installation CocoaPods Extendy is available through CocoaPods. To install i

Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects

SwiftyPick πŸ¦… πŸ’ Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects. Purpose The idea behind t

Useful extensions for my Swift code
Useful extensions for my Swift code

UIViewController extensions presentAlert(withTitle title: String, message : String) presentAlertDialog(withTitle title: String, message : String, acti

Steps and files needed to reproduce a CSP bug in Safari Web Extensions

CSP Safari bug repro There appears to be a discrepancy between how Safari handles CSP policies for extension pages compared to how other browsers do s

Personally useful Swift Extensions for iOS Development

Useful-Swift-Extensions Personally useful Swift Extensions for iOS Development; cobbled together from a variety of development projects and StackOverf

Swift extensions for asynchronous CloudKit record processing

⛅️ AsyncCloudKit Swift extensions for asynchronous CloudKit record processing. D

Easier sharing of structured data between iOS applications and share extensions
Easier sharing of structured data between iOS applications and share extensions

XExtensionItem XExtensionItem is a tiny library allowing for easier sharing of structured data between iOS applications and share extensions. It is ta

Extensions for Swift Standard Types and Classes

Cent Cent is a library that extends certain Swift object types using the extension feature and gives its two cents to Swift language. Dollar is a Swif

Releases(0.6-beta)
Owner
Dane4ka
Dane4ka
A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed.

Bookmark A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed. This class wraps Swift's URL

Darren Ford 8 Nov 3, 2022
How Swift standard types and classes were supposed to work.

How Swift standard types and classes were supposed to work. A collection of useful extensions for the Swift Standard Library, Foundation, and UIKit.

Goktug Yilmaz 3k Dec 22, 2022
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift.

Easy way to detect device environment: Device model and version Screen resolution Interface orientation iOS version Battery state Environment Helps to

Anatoliy Voropay 582 Dec 25, 2022
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.

Features β€’ Classes and Extensions Compatibility β€’ Requirements β€’ Communication β€’ Contributing β€’ Installing and Usage β€’ Documentation β€’ Changelog β€’ Exa

Fabrizio Brancati 992 Dec 2, 2022
Extensions giving Swift's Codable API type inference super powers πŸ¦Έβ€β™‚οΈπŸ¦Ήβ€β™€οΈ

Welcome to Codextended β€” a suite of extensions that aims to make Swift’s Codable API easier to use by giving it type inference-powered capabilities an

John Sundell 1.4k Jan 2, 2023
A handy collection of more than 500 native Swift extensions to boost your productivity.

SwifterSwift is a collection of over 500 native Swift extensions, with handy methods, syntactic sugar, and performance improvements for wide range of

SwifterSwift 12k Jan 7, 2023
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Zamzam Inc. 261 Dec 15, 2022
Handy Combine extensions on NSObject, including Set.

Storable Description If you're using Combine, you've probably encountered the following code more than a few times. class Object: NSObject { var c

hcrane 23 Dec 13, 2022
🌀 Swift Combine extensions for asynchronous CloudKit record processing

Swift Combine extensions for asynchronous CloudKit record processing. Designed for simplicity.

Chris Araman 46 Dec 8, 2022
SharkUtils is a collection of Swift extensions, handy methods and syntactical sugar that we use within our iOS projects at Gymshark.

SharkUtils is a collection of Swift extensions, handy methods and syntactical sugar that we use within our iOS projects at Gymshark.

Gymshark 1 Jul 6, 2021