### File

`src/experimental.service.ts`

### Index

###### Properties

- Static experimentalEnabled
- Private experiments

###### Methods

- addExperiment
- disableExperiment
- enableExperiment
- getExperiment
- getExperiments

###### Accessors

- isExperimental

### Methods

addExperiment
`addExperiment(name: string, options: Experiment)`
Defined in src/experimental.service.ts:43

Adds an experiment if it doesn't exist.

Parameters :

Name | Type | Optional | Default value
name | `string` | No |
options | `Experiment` | No | `{enabled: false}`

Returns : `void`

disableExperiment
`disableExperiment(name: string)`
Defined in src/experimental.service.ts:62

Disables an experiment by name

Parameters :

Name | Type | Optional | Description
name | `string` | No | `name of the experiment to disable`

Returns : `void`

enableExperiment
`enableExperiment(name: string)`
Defined in src/experimental.service.ts:53

Enables an experiment by name

Parameters :

Name | Type | Optional | Description
name | `string` | No | `name of the experiment to enable`

Returns : `void`

getExperiment
`getExperiment(name: string)`
Defined in src/experimental.service.ts:71

Get the options for an experiment by name

Parameters :

Name | Type | Optional | Description
name | `string` | No | `name of experiment to get`

Returns : `Experiment`

getExperiments
`getExperiments()`
Defined in src/experimental.service.ts:83
Get an array of tuples representing an experiment and it's options Returns : `Array<>`

### Properties

Static experimentalEnabled
`experimentalEnabled: ```
Default value : `true`
Defined in src/experimental.service.ts:17
Tracks if the v10 experimental mode is enabled

Private experiments
`experiments: ```
Default value : `new Map<string, Experiment>()`
Defined in src/experimental.service.ts:38
Map to hold all our experiments

### Accessors

isExperimental
get `isExperimental()`
Defined in src/experimental.service.ts:31
Gets the state of the v10 experimental mode
set `isExperimental(v: boolean)`
Defined in src/experimental.service.ts:23

Sets the v10 experimental mode

Parameters :

Name | Type | Optional
v | `boolean` | No

Returns : `void`

    import { Injectable } from "@angular/core";

    /**
     * Represents options for an experiment. The only required property is `enabled`, however other options may be supplied.
     */
    export interface Experiment {
    	enabled: boolean;
    	[key: string]: any;
    }

    @Injectable()
    export class ExperimentalService {
    	/**
    	 * Tracks if the v10 experimental mode is enabled
    	 * @deprecated since v3
    	 */
    	static experimentalEnabled = true;

    	/**
    	 * Sets the v10 experimental mode
    	 * @deprecated since v3
    	 */
    	set isExperimental(v: boolean) {
    		ExperimentalService.experimentalEnabled = v;
    	}

    	/**
    	 * Gets the state of the v10 experimental mode
    	 * @deprecated since v3
    	 */
    	get isExperimental() {
    		return ExperimentalService.experimentalEnabled;
    	}

    	/**
    	 * Map to hold all our experiments
    	 */
    	private experiments = new Map<string, Experiment>();

    	/**
    	 * Adds an experiment if it doesn't exist.
    	 */
    	addExperiment(name: string, options: Experiment = {enabled: false}) {
    		if (!this.experiments.has(name)) {
    			this.experiments.set(name, options);
    		}
    	}

    	/**
    	 * Enables an experiment by name
    	 * @param name name of the experiment to enable
    	 */
    	enableExperiment(name: string) {
    		const experiment = this.getExperiment(name);
    		experiment.enabled = true;
    	}

    	/**
    	 * Disables an experiment by name
    	 * @param name name of the experiment to disable
    	 */
    	disableExperiment(name: string) {
    		const experiment = this.getExperiment(name);
    		experiment.enabled = false;
    	}

    	/**
    	 * Get the options for an experiment by name
    	 * @param name name of experiment to get
    	 */
    	getExperiment(name: string): Experiment {
    		if (!this.experiments.has(name)) {
    			this.addExperiment(name);
    			return this.getExperiment(name);
    		}

    		return this.experiments.get(name);
    	}

    	/**
    	 * Get an array of tuples representing an experiment and it's options
    	 */
    	getExperiments(): Array<[string, Experiment]> {
    		return Array.from(this.experiments.entries());
    	}
    }

# result-matching ""

# No results matching ""