import { DataRequestDescriptor , DataRequestMeta } from '../../../common/descriptor_types' ; export class DataRequest { private readonly _descriptor : DataRequestDescriptor ; constructor ( descriptor ) { this . _descriptor = { ... descriptor , } ; } getData ( ) { return this . _descriptor . data ; } isLoading ( ) { return ! ! this . _descriptor . dataRequestToken ; } getMeta ( ) { if ( this . _descriptor . dataRequestMetaAtStart ) { return this . _descriptor . dataRequestMetaAtStart ; } else if ( this . _descriptor . dataRequestMeta ) { return this . _descriptor . dataRequestMeta ; } else { return { } ; } } hasData ( ) { return ! ! this . _descriptor . data ; } hasDataOrRequestInProgress ( ) { return this . hasData ( ) || this . isLoading ( ) ; } getDataId ( ) { return this . _descriptor . dataId ; } getRequestToken ( ) { return this . _descriptor . dataRequestToken ; } } export class DataRequestAbortError extends Error { constructor ( ) { super ( ) ; } }