Skip to content

Latest commit

 

History

History

Combine

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Combine

PublishSubject

Wrapper for Combine.PassthroughSubject that forces failure type to Never, so you don't need to write it every time you declare publisher type.

Before:

let exampleSubject = PassthroughSubject<Bool, Never>()

After:

let exampleSubject = PublishSubject<Bool>()

ValueSubject

Wrapper for Combine.CurrentValueSubject that forces failure type to Never, so you don't need to write it every time you declare publisher type.

Before:

let exampleSubject = CurrentValueSubject<Bool, Never>(false)

After:

let exampleSubject = ValueSubject<Bool>(false)

Publisher extensions

asVoid()

Simplifies dropping publisher values with mapping them to Void(). Reduces usage of empty arguments and braces in code for better readability.

Before:

exampleSubject
    .map { _ in Void() }
    .sink {}

After:

exampleSubject
    .asVoid()
    .sink {}

filterNil()

Simplifies dropping nil values in publisher with optional output type. Reduces usage of short braces in code for better readability.

Before:

exampleOptionalSubject
    .compactMap { $0.value }
    .sink {}

After:

exampleOptionalSubject
    .filterNil()
    .sink {}

firstNotNil()

Simplifies subscribing to first not nil value in publisher with optional output type. Reduces usage of short braces in code for better readability.

Before:

exampleOptionalSubject
    .first { $0.value != nil }
    .sink {}

After:

exampleOptionalSubject
    .firstNotNil()
    .sink {}