### File

`src/lib/decorators/use-data-source.ts`

### Index

###### Properties
dataSource Optional lastValue Optional settings

### Properties

dataSource
`dataSource: `IdOrInstanceOrToken<BaseDataSource>``
Type : `IdOrInstanceOrToken<BaseDataSource>`

lastValue
`lastValue: `Target``
Type : `Target`
Optional
The last value of the data source

settings
`settings: `UseDataSourceSettings<Source | Target>``
Type : `UseDataSourceSettings<Source | Target>`
Optional

    import { BaseDataSource } from '@rxap/data-source';
    import { FormSystemMetadataKeys } from './metadata-keys';
    import { IdOrInstanceOrToken } from '@rxap/definition';
    import { setMetadataMapMap } from '@rxap/reflect-metadata';

    export interface UseDataSourceSettings<Source = any, Target = Source> {
      transformer?: (source: Source) => Target;
    }

    export interface UseDataSourceValue<Source = any, Target = Source> {
      dataSource: IdOrInstanceOrToken<BaseDataSource>,
      settings?: UseDataSourceSettings<Source, Target>,

      /**
       * The last value of the data source
       */
      lastValue?: Target,
    }

    export function UseDataSource<Data>(
      dataSource: IdOrInstanceOrToken<BaseDataSource<Data>>,
      name: string,
      settings?: UseDataSourceSettings,
    ) {
      return function (target: any, propertyKey: string) {
        const value: UseDataSourceValue<Data> = {
          dataSource,
          settings,
        };
        setMetadataMapMap(propertyKey, name, value, FormSystemMetadataKeys.DATA_SOURCES, target);
      };
    }

# results matching ""

# No results matching ""