Giter Site home page Giter Site logo

featherquill's Introduction

FeatherQuill

Easily rollout your new features to segments of your audience.

SwiftPM Twitter GitHub GitHub issues GitHub Workflow Status

Codecov CodeFactor Grade codebeat badge Code Climate maintainability Code Climate technical debt Code Climate issues Reviewed by Hound

Features

FeatherQuill is a Swift package that provides a mechanism for implementing offline feature flags in your application. Feature flags allow you to enable or disable features for different users or segments of your user base without requiring a server-side update. This can be useful for A/B testing, rollout strategies, and more.

  • Offline Support: Feature flags are stored locally on the device, so they can be used even when the device is not connected to the internet.
  • Audience Targeting: You can target feature flags to specific users or segments of users based on criteria such as user ID or device type.
  • SwiftUI Integration: Provides a Feature struct that integrates seamlessly with SwiftUI for easy feature access in your views.

Requirements

Apple Platforms

  • Xcode 15.3 or later
  • Swift 5.10 or later
  • iOS 17 / watchOS 10 / tvOS 17 / visionOS 1 / macCatalyst 17 / macOS 14 or later deployment targets

Linux

  • Ubuntu 20.04 or later
  • Swift 5.10 or later

Installation

To add the FeatherQuill package to your Xcode project, select File > Swift Packages > Add Package Dependency and enter the repository URL.

Using Swift Package Manager add the repository url:

dependencies: [
  .package(url: "https://github.com/brightdigit/FeatherQuill", from: "1.0.0-alpha.1")
]

Usage

FeatherQuill leverages protocols and generics for a flexible and type-safe experience. Here's a simplified example of how to define and use a feature:

// Define a user type (e.g., user roles)
public enum UserRole: UserType {
  case free
  case pro
  case admin

  public static var `default`: UserRole {
    return .free
  }
}

// Define a feature with a default value and targeting
struct MyFeature: FeatureFlag {
  static var audience: UserRole { .pro }
  static var probability: Double { 0.2 } // 20% chance of being enabled
  static var initialValue: Bool { false }
  static var options: AvailabilityOptions { .default }

  @Sendable
  static func evaluateUser(_ userType: UserRole) async -> Bool {
    // Optional: Implement custom user evaluation logic here
    return true
  }
}

extension EnvironmentValues {
  public var newDesignFeature: MyFeature.Feature { self[MyFeature.self] }
}

// Accessing the feature in a SwiftUI view
struct MyView: View {
  @Environment(\.myFeature) var myFeature

  var body: some View {
    if myFeature.isAvailable {
      Toggle("Is Enabled", isOn: myFeature.bindingValue)
    } else {
      Text("This feature is disabled.")
    }
  }
}

License

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

featherquill's People

Contributors

leogdion avatar

Stargazers

Geoffrey Foster avatar Thomas Harr avatar Willi Wu avatar Ali A. Hilal avatar Bob Edmonston avatar Jérôme Alves avatar Tim Kersey avatar Muhammad Umer avatar Thomas Durand avatar Firdavs Khaydarov avatar Kotaro Suto avatar Matt Massicotte avatar Sunghyun Kim avatar

Watchers

 avatar

Forkers

mumer92

featherquill's Issues

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.