Latest 0.2.0
Homepage https://github.com/VIPER-Swift/VIPERS-Router-Protocol
License MIT
Platforms ios 8.0
Dependencies VIPERS-Converter-Protocol
Authors

[![CI Status](http://img.shields.io/travis/Jan Bartel/VIPERS-Router-Protocol.svg?style=flat)](https://travis-ci.org/Jan Bartel/VIPERS-Router-Protocol)
Version
License
Platform

Protocols for the router implementation used by the iOS application framework ‘VIPERS’.

At first a very abstract definition (practical information can be found after that ;)):

A router is an object that maps from a routeable item (an object conforming to the empty protocol RoutableProtocol) to a specific Route-Description (an object conforming to the empty protocol RouteDescriptionProtocol). It therefore uses a RouteDefinition (an object conforming to an empty RouteDefinitionProtocol) to map from a Routable to a RouteDescription. A router can therefore convert the Routeable to a RouteDescription and can additionally run a closure wich gets the RouteDescription as a parameter.

Lets become more practical, the VIPERS default implementation of the RouterProtocol in VIPERS is the DefaultRouter.
A default router maps from a routable string to a DefaultRoute which contains the identifier of the route (the routable string), and some parameters extracted from it.

It should look like that:


let router = DefaultRouter()
let routeDefinition : String = "/testRoute/:id"

do {
    try router.addRouteDefinition(routeDefinition) { ( route : DefaultRoute ) in
        print("this block is called when router.routeAndCallHandler is called with a valid routable")
        print("identifier: (route.identifier)")
        print("parameters: (route.parameters)")
    }

    let route1 : DefaultRoute = try router.routeAndCallHandler("/testRoute/15")
    print("route1: (route1)")

} catch let error {
    // implement your error handling here 
}

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

VIPERS-Router-Protocol is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "VIPERS-Router-Protocol"

Author

Jan Bartel, [email protected]

License

VIPERS-Router-Protocol is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "VIPERS-Router-Protocol",
    "version": "0.2.0",
    "summary": "Protocols for the router implementation used by the iOS application framework 'VIPERS'",
    "description": "Protocols for the router implementation used by the iOS application framework 'VIPERS'.",
    "homepage": "https://github.com/VIPER-Swift/VIPERS-Router-Protocol",
    "license": "MIT",
    "authors": {
        "Jan Bartel": "[email protected]"
    },
    "source": {
        "git": "https://github.com/VIPER-Swift/VIPERS-Router-Protocol.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "VIPERS-Router-Protocol/Classes/**/*",
    "dependencies": {
        "VIPERS-Converter-Protocol": []
    }
}

Pin It on Pinterest

Share This