Giter Club home page Giter Club logo

realflags's Introduction

RealFlags

RealFlags makes it easy to configure feature flagsin your codebase.
It's designed for Swift and provides a simple and elegant abstraction layer over multiple providers you can query with your own priority.
It also comes with an handy UI tool to browse and alter values directly at runtime!


Features | What You Get | Flags Browser & Editor | Tests | Documentation | Requirements | Installation | Powered Apps | Support & Contribute | License


Features Highlights

  • ๐Ÿ’ก Simple & Elegant: Effectively describe and organize your own flags with a type-safe structure. It will abstract your implementation and consistently reduce the amount of code to manage your feature flags
  • ๐Ÿ’ก Extensible: You can use one of the default data providers or create your own. We support Firebase Remote and Local configurations too
  • ๐Ÿ’ก Complete: Feature Flags supports all primitive datatypes and complex objects: Int (and any numeric variant), String, Bool, Data, Date, URL, Dictionary, Array (values must conform to FlagProtocol), Optional Values and virtually any object conforms to Codable protocol!
  • ๐Ÿ’ก Configurable: Enable, disable and customize features at runtime
  • ๐Ÿ’ก Integrated UI Tool: the handy UI Tool allows you to customize and read flags at glance

An Hands-on Approach

Would you use RealFlags in your product? We wrote an article about it.
Check it out here

What You Get

Our goal making RealFlags is to provide a type-safe abstract way to describe and query for feature flags.

The first step is to describe your collection of flags:

// Define the structure of your feature flags with type-safe properties!
struct UserFlags: FlagCollectionProtocol {
    @Flag(default: true, description: "Show social login options along native login form")
    var showSocialLogin: Bool
    
    @Flag(default: 0, description: "Maximum login attempts before blocking account")
    var maxLoginAttempts: Int
    
    @Flag(key: "rating_mode", default: "at_launch", description: "The behaviour to show the rating popup")
    var appReviewRating: String

    public init() {}
}

This represent a type-safe description of some flags grouped in a collection. Each feature flags property is identified by the @Flag annotation. It's time load values for this collection; using a new FlagsLoader you will be able to load and query collection's values from one or more data provider:

// Allocate your own data providers
let localProvider = LocalProvider(localURL: fileURL)
let fbProvider = FirebaseRemoteProvider()

// Loader is the point for query values
let userFlagsLoader = FlagsLoader(UserFlags.self, // load flags definition
                                  description: .init(name: "User Features", description: "Cool experimental features for user account"),
                                  providers: [fbProvider, localProvider]) // set providers

Now you can query values from userFlagsLoader by using the UserFlags structure (it suppports autocomplete and type-safe value thanks to @dynamicMemberLookup!).
Let me show it:

if userFlagsLoader.showSocialLogin { // query properties as type-safe with autocomplete!
    // do some stuff
}

Values are obtained respecting the order you have specified, in this case from Firebase Remote Config service then, when no value is found, into the local repository.
If no values are available the default value specified in @Flags annotation is returned.

This is just an overview of the library; if you want to know more follow the documentation below.

Flags Browser & Editor

RealFlags also comes with an handy tool you can use to browse and edit feature flags values directly in your client! It can be useful for testing purpose or allow product owners to enable/disable and verify features of the app.

Checkout the doc for more infos!

flags_browser_video.mp4

Tests

RealFlags includes an extensive collection of unit tests: you can found it into the Tests directory.

Documentation

The following documentation describe detailed usage of the library.

Requirements

RealFlags can be installed in any platform which supports Swift 5.4+ including Windows and Linux. On Apple platform the following configuration is required:

  • iOS 12+
  • Xcode 12.5+
  • Swift 5.4+

Installation

To use RealFlags in your project you can use Swift Package Manager (our primary choice) or CocoaPods.

Swift Package Manager

Aadd it as a dependency in a Swift Package, add it to your Package.swift:

dependencies: [
    .package(url: "https://github.com/immobiliare/RealFlags.git", from: "1.0.0")
]

And add it as a dependency of your target:

targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "https://github.com/immobiliare/RealFlags.git", package: "RealFlags")
    ])
]

In Xcode 11+ you can also navigate to the File menu and choose Swift Packages -> Add Package Dependency..., then enter the repository URL and version details.

CocoaPods

RealFlags can be installed with CocoaPods by adding pod 'RealFlags' to your Podfile.

pod 'RealFlags' // to import the core framework
pod 'RealFlagsFirebase' // to also import Firebase Data Provider

Powered Apps

RealFlags was created by the amazing mobile team at ImmobiliareLabs, the Tech dept at Immobiliare.it, the first real estate site in Italy.
We are currently using RealFlags in all of our products.

If you are using RealFlags in your app drop us a message, we'll add below.

Indomio

Support

Made with โค๏ธ by ImmobiliareLabs and Contributors

We'd love for you to contribute to RealFlags!
If you have any questions on how to use RealFlags, bugs and enhancement please feel free to reach out by opening a GitHub Issue.

License

RealFlags is licensed under the MIT license.
See the LICENSE file for more information.

realflags's People

Contributors

antranapp avatar jellybellydev avatar malcommac avatar

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.