data source v0.0.34
This commit is contained in:
		
							parent
							
								
									71a4d01930
								
							
						
					
					
						commit
						36fb823902
					
				| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "data", |   "name": "data", | ||||||
|   "version": "0.0.28", |   "version": "0.0.29", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "ng": "ng", |     "ng": "ng", | ||||||
|     "start": "ng serve", |     "start": "ng serve", | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "@poweredsoft/data", |   "name": "@poweredsoft/data", | ||||||
|   "version": "0.0.33", |   "version": "0.0.34", | ||||||
|   "peerDependencies": { |   "peerDependencies": { | ||||||
|     "rxjs": "^6.5.3" |     "rxjs": "^6.5.3" | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ import { IDataSourceErrorMessage } from './IDataSourceErrorMessage'; | |||||||
| import { IDataSourceValidationError } from './IDataSourceValidationError'; | import { IDataSourceValidationError } from './IDataSourceValidationError'; | ||||||
| import { IDataSourceError } from './IDataSourceError'; | import { IDataSourceError } from './IDataSourceError'; | ||||||
| import { IDataSourceNotifyMessage } from './IDataSourceNotifyMessage'; | import { IDataSourceNotifyMessage } from './IDataSourceNotifyMessage'; | ||||||
|  | import { IDataSourceCommandStarted } from './IDataSourceCommandStarted'; | ||||||
| 
 | 
 | ||||||
| export class DataSource<TModel> implements IDataSource<TModel>  | export class DataSource<TModel> implements IDataSource<TModel>  | ||||||
| { | { | ||||||
| @ -15,12 +16,14 @@ export class DataSource<TModel> implements IDataSource<TModel> | |||||||
|     protected _dataSubject: BehaviorSubject<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>> = new BehaviorSubject(null); |     protected _dataSubject: BehaviorSubject<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>> = new BehaviorSubject(null); | ||||||
|     protected _loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject(false); |     protected _loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject(false); | ||||||
|     protected _validationSubject: Subject<IDataSourceValidationError> = new Subject(); |     protected _validationSubject: Subject<IDataSourceValidationError> = new Subject(); | ||||||
|  |     protected _commandStartedSubject: Subject<IDataSourceCommandStarted> = new Subject(); | ||||||
|     protected _notifyMessageSubject: Subject<IDataSourceNotifyMessage> = new Subject(); |     protected _notifyMessageSubject: Subject<IDataSourceNotifyMessage> = new Subject(); | ||||||
| 
 | 
 | ||||||
|     protected _data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>; |     protected _data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>; | ||||||
|     protected _loading$: Observable<boolean>; |     protected _loading$: Observable<boolean>; | ||||||
|     protected _validationError$: Observable<IDataSourceValidationError>; |     protected _validationError$: Observable<IDataSourceValidationError>; | ||||||
|     protected _notifyMessage$: Observable<IDataSourceNotifyMessage>; |     protected _notifyMessage$: Observable<IDataSourceNotifyMessage>; | ||||||
|  |     protected _commandStarted$: Observable<IDataSourceCommandStarted>; | ||||||
|      |      | ||||||
|     protected _criteria: IQueryCriteria = { |     protected _criteria: IQueryCriteria = { | ||||||
|         page: null, |         page: null, | ||||||
| @ -52,6 +55,14 @@ export class DataSource<TModel> implements IDataSource<TModel> | |||||||
|         return this._validationError$; |         return this._validationError$; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     get commandStarted$() { | ||||||
|  |         if (!this._commandStarted$) | ||||||
|  |             this._commandStarted$ = this._commandStartedSubject.asObservable(); | ||||||
|  | 
 | ||||||
|  |         return this._commandStarted$; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     get notifyMessage$() { |     get notifyMessage$() { | ||||||
|         if (!this._notifyMessage$) |         if (!this._notifyMessage$) | ||||||
|             this._notifyMessage$ = this._notifyMessageSubject.asObservable(); |             this._notifyMessage$ = this._notifyMessageSubject.asObservable(); | ||||||
| @ -138,6 +149,10 @@ export class DataSource<TModel> implements IDataSource<TModel> | |||||||
|         if (!this.options.transport.commands.hasOwnProperty(name)) |         if (!this.options.transport.commands.hasOwnProperty(name)) | ||||||
|             return throwError(`command with name ${name} not found`); |             return throwError(`command with name ${name} not found`); | ||||||
| 
 | 
 | ||||||
|  |         this._commandStartedSubject.next({ | ||||||
|  |             name: name, command: command | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|         return this.options.transport.commands[name].adapter.handle(command).pipe( |         return this.options.transport.commands[name].adapter.handle(command).pipe( | ||||||
|             map(t => { |             map(t => { | ||||||
|                 this._notifyMessageSubject.next({ |                 this._notifyMessageSubject.next({ | ||||||
|  | |||||||
| @ -0,0 +1,5 @@ | |||||||
|  | 
 | ||||||
|  | export interface IDataSourceCommandStarted { | ||||||
|  |     name: string; | ||||||
|  |     command: any; | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user