### File

`src/lib/mixins/extract-data-sources.mixin.ts`

### Index

###### Methods
Protected extractDataSources

### Methods

Protected extractDataSources
`extractDataSources(formDefinition: FormDefinition, controlId: string)`
Defined in src/lib/mixins/extract-data-sources.mixin.ts:9
Parameters :
Name | Type | Optional
formDefinition | `FormDefinition` | No
controlId | `string` | No
Returns : `Map<string, UseDataSourceValue>`

    import { FormDefinition } from '@rxap/forms';
    import { RxapFormSystemError } from '../error';
    import { FormSystemMetadataKeys } from '../decorators/metadata-keys';
    import { UseDataSourceValue } from '../decorators/use-data-source';
    import { getMetadata } from '@rxap/reflect-metadata';

    export class ExtractDataSourcesMixin {

      protected extractDataSources(formDefinition: FormDefinition, controlId: string): Map<string, UseDataSourceValue> {
        const map = getMetadata<Map<string, Map<string, UseDataSourceValue>>>(
          FormSystemMetadataKeys.DATA_SOURCES,
          Object.getPrototypeOf(formDefinition),
        );

        if (!map) {
          throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
        }

        if (!map.has(controlId)) {
          throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
        }

        return map.get(controlId)!;
      }

    }

# results matching ""

# No results matching ""