Module EnvironmentModule

Environment Module

An environment object with all the implemented services.

createEnvironmentModule()

Creates an environment module with all the default implementations and starts the load of properties.

import { createEnvironmentModule, EnvironmentModule, EnvironmentSource } from '@kuoki/environment';

const source: EnvironmentSource = { load: () => [{ a: 0 }] };
const environmentModule: EnvironmentModule = await createEnvironmentModule(source);

environmentModule.query.get('a'); // 0

Use cases

Below are examples of use cases.

Table of Contents
  1. Load of async properties

Load of async properties

If the source load asynchronous non required properties always use the async or reactive version of the methods to ensure that the call waits for the source to finish the load.

import { createEnvironmentModule, EnvironmentModule, EnvironmentSource } from '@kuoki/environment';

// env.json = {a:0}
const source: EnvironmentSource = {
load: () => fetch('env.json').then((response: Response) => response.json())
};
const environmentModule: EnvironmentModule = await createEnvironmentModule(source);

environmentModule.query.get('a'); // undefined
await environmentModule.query.getAsync('a'); // 0

Index

Interfaces

Functions

Generated using TypeDoc