Skip to content

CaptureContext/combine-extensions

Repository files navigation

combine-extensions

CI

Extensions for Apple Combine framework.

Note

The package is in beta

TODO

  • Proxies

    • DelegateProxy
    • PublishersProxy
    extension PublishersProxy where Base: UISearchBar {
      /// Combine wrapper for `UISearchBarDelegate.searchBarCancelButtonClicked(_:)`
    	public var cancelButtonClicked: some Publisher<Void, Never> {
    		let selector = _makeMethodSelector(
    			selector: #selector(UISearchBarDelegate.searchBarCancelButtonClicked(_:)),
    			signature: base.delegate?.searchBarCancelButtonClicked(_:)
    		)
    		return delegateProxy.proxy_intercept(selector).replaceOutput(with: ())
    	}
    
    	private var delegateProxy: UISearchBarDelegateProxy {
    		.proxy(for: base, \.delegate)
    	}
    }
    
    private class UISearchBarDelegateProxy: 
      DelegateProxy<UISearchBarDelegate>, 
      UISearchBarDelegate 
    {}
  • TypeErasure

    • NoOptionsScheduler
    • AnySubject
    • AnySubscriber
  • Selectors interception

    See combine-interception

  • Cancellables

    • NonScopedCancellable
  • Operators

    • SinkEvents
    • SinkValues
  • Subjects:

    • PublishSubject
    • OpenPublishSubject
  • Subscribers

    • CancelTrackingSubscriber
  • Subscriptions

    • CancelTrackingSubscription
  • Lifetime

  • DemandBuffer

  • Materialize/Dematerialize

  • Relays

  • Look at CombineExt for more ideas

Exports

Installation

Basic

You can add CombineExtensions to an Xcode project by adding it as a package dependency.

  1. From the File menu, select Swift Packages › Add Package Dependency…
  2. Enter "https://github.com/capturecontext/combine-extensions.git" into the package repository URL text field
  3. Choose products you need to link them to your project.

Recommended

If you use SwiftPM for your project, you can add CombineExtensions to your package file.

.package(
  url: "https://github.com/capturecontext/combine-extensions.git", 
  .upToNextMinor(from: "0.3.0")
)

Do not forget about target dependencies:

.product(
  name: "CombineExtensions", 
  package: "combine-extensions"
)
.product(
  name: "CombineExtensionsMacros", 
  package: "combine-extensions"
)

Note

The package is compatible with non-Apple platforms, however this package uses conditional compilation, so APIs are only available on Apple platforms

License

This library is released under the MIT license. See LICENCE for details.

See [ACKNOWLEDGMENTS][ACKNOWLEDGMENTS] for inspiration references and their licences.