Latest 0.1.0
Homepage https://github.com/threeplay/TPFeatureTag
License MIT
Platforms ios 10.0
Authors

CI Status
Version
License
Platform

Simple feature tags managment for swift projects

Usage

Define your feature tags


// Subclass FeatureTags to get automatic feature registration
class Features: FeatureTags {
  let feature1 = makeFeature()
  let feature2 = makeFeature(key: "remote_feature1", enabled: true)
}

// Singleton instance for features 
let features = Features()

Check if a feature is enabled or not

...
  if features.feature1.isOn {
      // Code to execute if feature is enabled
  } else {
      // Code to execute if feature is disabled
  }
...

Install resolver(s)

...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  ...
  FeatureTags.Manager.install(name: 'local', priority: 10, resolver: FeatureTags.Resolvers.Local(namespace: 'featuretags'))
  ...
}

Update feature tags state in a specific resolver

// Set a value if resolver supports it (ignored if setting is not supported)
FeatureTags.Manager.instance.set(features.feature1, to: true, in: 'local')

// Remove a value and allow an higher priority resolver to resolve a value
FeatureTags.Manager.instance.remove(features.feature1, from: 'local')

Update feature tags state for all resolvers

// Set a value if resolver supports it (ignored if setting is not supported)
FeatureTags.Manager.instance.set(features.feature1, to: true)

// Remove a value and allow an higher priority resolver to resolve a value
FeatureTags.Manager.instance.remove(features.feature1)

Get a list of registered feature tags

let allFeatures = FeatureTags.Manager.instance.allFeatures

Each feature returned contains:

  • name generated by reflection from the variable name
  • namespace generated by reflection from the containing class
  • key assigned by makeFeature
  • isOn current resolved state of the feature from the highest priority resolver that returned a value to that feature tag
  • source the resolver’s name that returned the value default if no resolver returns a value and using the makeFeature default

Installation

TPFeatureTag is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'TPFeatureTag'

Author

Eliran Ben-Ezra, [email protected]

License

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

Latest podspec

{
    "name": "TPFeatureTag",
    "version": "0.1.0",
    "summary": "Simple boolean feature tags manager.",
    "description": "Simple boolean feature tags manager with name spaced feature tags and custom value resolvers",
    "homepage": "https://github.com/threeplay/TPFeatureTag",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Eliran Ben-Ezra": "[email protected]"
    },
    "source": {
        "git": "https://github.com/threeplay/TPFeatureTag.git",
        "tag": "0.1.0"
    },
    "swift_version": "4.2",
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "TPFeatureTag/Classes/**/*"
}

Pin It on Pinterest

Share This