Comments (1)
Sometimes you may want to alter the default value of a Flag
set via the annotation default
parameters.
This is true when, for example, you have different target of your product with different values for some flag and you would avoid creating duplicate files for each Flags Collection blue print.
In this case you can define your own FlagsCollection
s and use the setDefaultValue()
on each different flag to setup your own value.
Consider this example:
struct Flags: FlagCollectionProtocol {
@FlagCollection(default: 100, description: "...")
var flagA: Int
@Flag(default: false, description: "...")
var flagB: Bool
}
public func setupFlagsByTarget {
self.loader = FlagsLoader(Flags.self, provider: [...])
#if TARGET_A
// Target A only differ for a 200 default value for flagA
loader.$flagA.setDefault(200)
#endif
#if TARGET_B
// Target B only differ in flagB which is false by default
loader.$flagB.setDefault(false)
#endif
#if TARGET_C
// Target C has the same false for flagB but a different value for flagA
loader.$flagA.setDefault(50)
#endif
}
from realflags.
Related Issues (16)
- LocalProvider fail to throw error if something went wrong saving local flags
- Make the Flags Browser more user friendly for general purpose users
- Search support for feature flags in Browser Controller
- Support for Optimizely data provider
- Reset values for LocalProvider and per flag in every writable provider HOT 1
- FlagProvider's flagValue(from:fallback) function ignores fallback setting
- Better presentation for optional data inside the flags browser
- A Sample App would be nice HOT 1
- link to blog post broken
- Providers not respecting order defined HOT 3
- Firebase 10 support - Fork Link HOT 1
- [Bug]: instance! crashes sometimes
- Computed value for annotated feature flag
- Bundle for FlagsControllerBrowser's storyboard failed to instantiate via CocoaPods
- wrappedTypeFromOptionalType() function in FirebaseRemoteProvider works only with optional type, fails with non-optional
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realflags.