Module LoaderSource

Loader Source

EnvironmentSource with all the default values used by the loader.

Use cases

Table of Contents
  1. loaderSourceFactory
  2. loaderSourcesFactory
  3. Errors

loaderSourceFactory

The default values are:

{
id: 'random id',
isRequired: false,
isOrdered: false,
ignoreError: false,
strategy: SourceStrategy.ADD,
};
loaderSourceFactory({ load: () => [{}] });
// {
// id: '1fvtjeqav0.fpjcvk57vno',
// isRequired: false,
// isOrdered: false,
// ignoreError: false,
// strategy: SourceStrategy.ADD,
// load: () => [{}]
// }
const source = {
id: 'a',
isRequired: true,
isOrdered: true,
ignoreError: true,
strategy: SourceStrategy.MERGE,
path: 'a',
load: () => [{}]
};
loaderSourceFactory(source);
// {
// id: 'a',
// isRequired: true,
// isOrdered: true,
// ignoreError: true,
// strategy: SourceStrategy.MERGE,
// path: 'a',
// load: () => [{}]
// }
loaderSourceFactory({ load: 0 }); // throws InvalidSourceError

loaderSourcesFactory

const source1 = { load: () => [{ a: 0 }] };
loaderSourcesFactory(source1);
// [{
// id: '1fvtjeqav0.fpjcvk57vno',
// isRequired: false,
// isOrdered: false,
// ignoreError: false,
// strategy: SourceStrategy.ADD,
// load: () => [{a:0}]
// }]
const source1 = { load: () => [{ a: 0 }] };
const source2 = { load: () => [{ a: 1 }] };
loaderSourcesFactory([source1, source2]);
// [{
// id: '1fvtjeqav0.fpjcvk57vno',
// isRequired: false,
// isOrdered: false,
// ignoreError: false,
// strategy: SourceStrategy.ADD,
// load: () => [{a:0}]
// },
// {
// id: '1fvtjfh8q0.tnprppqrf3g',
// isRequired: false,
// isOrdered: false,
// ignoreError: false,
// strategy: SourceStrategy.ADD,
// load: () => [{a:1}]
// }]
loaderSourcesFactory({ load: 0 }); // throws InvalidSourceError
const source1 = { id: 'a', load: () => [{ a: 0 }] };
const source2 = { id: 'a', load: () => [{ a: 1 }] };
loaderSourcesFactory([source1, source2]); // throws DuplicatedSourcesError

Errors

new DuplicatedSourcesError(['a', 'b']); // There are sources with duplicate id's: a, b

Index

Classes

Type Aliases

Functions

Generated using TypeDoc