Swiftpack.co - e-sites/RxRouting as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by e-sites.
e-sites/RxRouting v1.2.0
Deeplink routing with the use of RxSwift
⭐️ 0
🕓 3 years ago
.package(url: "https://github.com/e-sites/RxRouting.git", from: "v1.2.0")

RxRouting

Swift CocoaPods Build Status Carthage compatible

RxRouting proves a reactive way to handle deeplinks.

Thanks to devxoul his URLNavigator library for (parts) of his url matching code

Installation

CocoaPods

pod 'RxRouting'

Carthage

github 'e-sites/RxRouting'

Getting started

// Handles an URL that is openened from an external application (e.g. Safari).
func handle(url: URL) -> Bool

// Registers a url pattern
func register(_ url: String) -> Observable<RouteMatchResult>

Usage

AppDelegate.swift

To handle links that open your app, forward the URL to RxRouting so it can be dispatched to the subscribed observers.

import RxRouting

func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    if RxRouting.instance.handle(url: url) {
        return true
    }
    return false
}

Registering

The listen for incoming URL's, register your pattern

RxRouting.instance
    .register("rxroutingexample://user/<userid:int>"
    .subscribe(onNext: { result in
        // result is a RouteMatchResult
    }.disposed(by: disposeBag)

Available patterns

Pattern Swift type Pattern Example
<value> String scheme://users/gender/<gender> scheme://users/gender/male
<value:int> Int scheme://user/<userid:int> scheme://user/5123
<value:float> Float scheme://temperatures/<temp:float> scheme://temperatures/31.5
<value:bool> Bool scheme://users/active/<available:bool> scheme://users/active/true
<value:uuid> UUID scheme://users/<userid:uuid> scheme://users/f3383db8-9a6d-494c-b1af-2438148204c0
<value:date> Date scheme://news/<newsdate:date> scheme://news/2019-06-22

GitHub

link
Stars: 0
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics