FeatureDefinition
public protocol FeatureDefinition : AnyObject
This is the basic information for all features of an application or framework.
Use specific sub-protocols Feature
and ConditionalFeature
in your code.
Note
Accesses to any properties that may change at runtime, e.g.variation
must only occur on the main thread.
-
name
Default implementationReturns a user-friendly name for this feature
Default Implementation
Generate the default name using the type name converted from camel case !!! TODO: Memoize this so it is not recreating every time.
Declaration
Swift
static var name: String { get }
-
Returns a user-friendly description for this feature
Declaration
Swift
static var description: String { get }
-
isVisible
Default implementationReturn
true
if this feature should appear in Feature selection UIs, such as toolbars.Note
This is purely for app use to categories some features as being surfaced in the UI. Visibility of individual actions is controlled by whether or not they arepublish()
‘d in theprepare
function of the feature.Note
Accesses to any properties that may change at runtime must only occur on the main thread.Default Implementation
By default, features are not visible to the user
Declaration
Swift
static var isVisible: Bool { get }
-
variation
Default implementationReturn the ID of a variation if this feature, if applicable for e.g. A/B testing.
Action.perform
can look at this value to decide how to implement the action based on this value.Note
Accesses to any properties that may change at runtime must only occur on the main thread.Default Implementation
By default, no variation. Override and supply your own variation values using whatever system you have for determining the A/B testing variations.
Declaration
Swift
static var variation: String? { get }
-
Called to initialise the feature at startup. Actionable implementations must call
declare
for all actions they support inside this function.Note
May be called multiple times in testsDeclaration
Swift
static func prepare(actions: FeatureActionsBuilder)
-
postPrepare()
Default implementationCalled to allow the feature to do any post-preparation after all features in the same feature group have prepared their actions.
Default implementation does nothing, override only if you need to do something.
Default Implementation
NO-OP
Declaration
Swift
static func postPrepare()
-
parent
Extension methodThis property is a convenience for the internal
Flint.parent(of: self)
. Don’t shadow it on your own Feature types by accident! If you override this you must declare its type explicitly as the optionalFeatureGroup.Type?
to prevent this problem.- return: the parent feature group of this feature, if any. Flint automatically handles this during preparation
and stashes the parent info in the
Flint
object.
Declaration
Swift
static var parent: FeatureGroup.Type? { get }
- return: the parent feature group of this feature, if any. Flint automatically handles this during preparation
and stashes the parent info in the
-
identifier
Extension methodGenerate the identifier using the feature-parent relationship to achieve nested IDs. This is not part of the public API, as IDs are for internal use only. !!! TODO: Memoize this so it is not recreating every time.
Declaration
Swift
static var identifier: FeaturePath { get }
-
logs(for:)
Extension methodReturns a set of new context-specific loggers with this feature as the context (topic path).
- param activity: A string that identifies the kind of activity that will be generating log entries, e.g.
bg upload
- return: A
Logs
value which contains development and production loggers as appropriate at runtime.
Declaration
Swift
static func logs(for activity: String) -> ContextualLoggers
- param activity: A string that identifies the kind of activity that will be generating log entries, e.g.
-
setLoggingLevel(_:)
Extension methodConvenience function to set the level of logging for this feature and subfeatures
Declaration
Swift
static func setLoggingLevel(_ level: LoggerLevel)
-
disableLogging()
Extension methodConvenience function to turn off logging for this feature and subfeatures
Declaration
Swift
static func disableLogging()