Re-design IEnvironment
Closed this issue · 1 comments
webJose commented
Purpose
Provide new properties that allow access to all environment definitions as well as the currently selected environment definition.
Design
- Replace the
value
property with acurrent
property of typeIEnvironmentDefinition
. - Replace the
names
property with aall
property of typeIEnvironmentDefinition[]
. - Add an
hasTraits()
function to test if the current environment contains the specified traits. - Ammend the specifier for any additional properties accordingly.
/**
* Defines the capabilities required from environment objects.
*/
export interface IEnvironment {
/**
* The current environment (represented by an environment definition).
*/
readonly current: IEnvironmentDefinition;
/**
* The list of known environments (represented by a list of environment definitions).
*/
readonly all: IEnvironmentDefinition[];
/**
* Tests the current environment definition for the presence of the specified traits. It will return true
* only if all specified traits are present; othewise it will return false.
* @param traits The environment traits expected to be found in the current environment definition.
*/
hasTraits(traits: Traits): boolean;
[x: string | 'current' | 'all' | 'hasTraits']: EnvironmentTest | IEnvironmentDefinition | IEnvironmentDefinition[] | ((Traits) => boolean)
}
Environment Class
- Add the
current
property to the class to comply with the changes done inIEnvironment
. - The list of environments received in the constructor needs to be checked so names are unique.
- The list of environments can be a list of strings, a mixture of strings and
IEnvironmentDefinition
objects, or pureIEnvironmentDefinition
objects. - Any environment received as a string will be converted to an
IEnvironmentDefinition
object with no traits. - By default, no-trait environments will define a numeric
traits
value of zero (0). - The environments must all adhere to the same trait data type: If one environment defines traits as a number, then all other environments must define traits as numbers, and ditto with the string data type.
webJose commented
Deployed in RC0.