Code Monkey home page Code Monkey logo

composable-deep-link's Introduction

ComposableDeepLink

ComposableDeepLink โ€“ is a Swift DSL library for handling deep links in a composable and flexible way.
It provides an approach to deep link processing, allowing you to define complex deep link handling logic using a composition of smaller components.

Features

  • Composable handlers for:
    • schemes
    • hosts
    • paths
    • parameters
  • Support for static and parameterized paths.
  • Easy-to-use syntax for defining deep link handling logic.

Installation

You can integrate ComposableDeepLink into your project using:

  • Swift Package Manager (SPM)
    • Add the following dependency to your Package.swift
      • .package(url: "https://github.com/xxKRASHxx/composable-deep-link", from: "0.2.0")
    • add ComposableDeepLink to your target's dependencies.
  • Xcode project
    1. From the File menu, select Add Packages...
    2. Enter "https://github.com/xxKRASHxx/composable-deep-link" into the package repository URL text field
    3. Import library to the reqired target

Usage

Here's a simple example demonstrating how to use ComposableDeepLink to handle deep links:

import ComposableDeepLink // 1. Import Library

enum DeepLink { // 2. Define result type
  case foo(id: String)
  case bar
  case biz
}

let processor = ComposableDeepLink<DeepLink> { // 3. Compose handling
  Scheme("myapp") {
    Host("example.host.com") {
      Path("/foo/:id") { context in
        Handle { // Handle the deep link logic here
          guard let id = context.id else { return nil }
          return .foo(id: id)
        }
      }
    }
    Host("another.host.com") {
      Path("/bar") { context in
        Handle { // Handle the deep link logic here
          .bar
        }
      }
      Path("/bar/biz") { context in
        Handle { // Handle the deep link logic here
          .biz
        }
      }
    }
  }
}

if let result = processor.handle(url: deepLinkURL) {
  // 4. Do something with the result
}

Contributing

Contributions are welcome!
If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request

License

ComposableDeepLink is available under the MIT license.
See the LICENSE file for more information.

composable-deep-link's People

Contributors

xxkrashxx avatar

Stargazers

 avatar Srdjan avatar

Watchers

 avatar

composable-deep-link's Issues

Path context autocomplete

Improve @dynamicMemberLookup implementation in order to enable autocomplete.
See:

  • Swift Macros
  • Libs: SwiftSyntax, SwiftSyntaxMacroExpansion, SwiftSyntaxMacros

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.