data source v0.0.34

This commit is contained in:
David Lebee 2021-08-25 18:26:29 -04:00
parent 71a4d01930
commit 36fb823902
4 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "data",
"version": "0.0.28",
"version": "0.0.29",
"scripts": {
"ng": "ng",
"start": "ng serve",

View File

@ -1,6 +1,6 @@
{
"name": "@poweredsoft/data",
"version": "0.0.33",
"version": "0.0.34",
"peerDependencies": {
"rxjs": "^6.5.3"
}

View File

@ -7,6 +7,7 @@ import { IDataSourceErrorMessage } from './IDataSourceErrorMessage';
import { IDataSourceValidationError } from './IDataSourceValidationError';
import { IDataSourceError } from './IDataSourceError';
import { IDataSourceNotifyMessage } from './IDataSourceNotifyMessage';
import { IDataSourceCommandStarted } from './IDataSourceCommandStarted';
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 _loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject(false);
protected _validationSubject: Subject<IDataSourceValidationError> = new Subject();
protected _commandStartedSubject: Subject<IDataSourceCommandStarted> = new Subject();
protected _notifyMessageSubject: Subject<IDataSourceNotifyMessage> = new Subject();
protected _data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
protected _loading$: Observable<boolean>;
protected _validationError$: Observable<IDataSourceValidationError>;
protected _notifyMessage$: Observable<IDataSourceNotifyMessage>;
protected _commandStarted$: Observable<IDataSourceCommandStarted>;
protected _criteria: IQueryCriteria = {
page: null,
@ -52,6 +55,14 @@ export class DataSource<TModel> implements IDataSource<TModel>
return this._validationError$;
}
get commandStarted$() {
if (!this._commandStarted$)
this._commandStarted$ = this._commandStartedSubject.asObservable();
return this._commandStarted$;
}
get notifyMessage$() {
if (!this._notifyMessage$)
this._notifyMessage$ = this._notifyMessageSubject.asObservable();
@ -138,6 +149,10 @@ export class DataSource<TModel> implements IDataSource<TModel>
if (!this.options.transport.commands.hasOwnProperty(name))
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(
map(t => {
this._notifyMessageSubject.next({

View File

@ -0,0 +1,5 @@
export interface IDataSourceCommandStarted {
name: string;
command: any;
}