Istered / RxPhotos

Reactive extensions for iOS Photos framework
MIT License
20 stars 2 forks source link
extension ios photos reactive rxswift swift

RxPhotos

CI Status Version License Platform Carthage compatible

This library is a tiny wrapper around some callback-based Photos' framework functions.

Usage

Request image:

PHImageManager.default().rx.requestImage(
            for: asset,
            targetSize: CGSize(width: 120, height: 200),
            contentMode: PHImageContentMode.aspectFit,
            options: nil
            ).subscribe(onNext: { image in
                //
            }).disposed(by: disposeBag)

Watch PHPhotoLibrary changes:

PHPhotoLibrary.shared().rx.photoLibraryChange
            .subscribe(onNext: { change in
                //
            }).disposed(by: disposeBag)

Request authorization:

PHPhotoLibrary.rx.requestAuthorization()
            .subscribe(onSuccess: { status in
                //
            }).disposed(by: disposeBag)

Perform changes on photo library:

PHPhotoLibrary.shared().rx.performChanges({ /**/ })
            .subscribe(onSuccess: { result in
                //
            }).disposed(by: disposeBag)

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate RxPhotos into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'RxPhotos'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate RxPhotos into your Xcode project using Carthage, specify it in your Cartfile:

github "istered/RxPhotos"

Run carthage update to build the framework and drag the built RxPhotos.framework into your Xcode project.

Dependencies

Requirements

Author

Anton Romanov

License

RxPhotos is available under the MIT license. See the LICENSE file for more info.