data source changes
This commit is contained in:
parent
bf08782a62
commit
9ec3000b85
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@poweredsoft/data",
|
"name": "@poweredsoft/data",
|
||||||
"version": "0.0.18",
|
"version": "0.0.20",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"rxjs": "^6.5.3"
|
"rxjs": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
this._criteria.filters = copy.filters || this._criteria.filters;
|
this._criteria.filters = copy.filters || this._criteria.filters;
|
||||||
this._criteria.groups = copy.groups || this._criteria.groups;
|
this._criteria.groups = copy.groups || this._criteria.groups;
|
||||||
this._criteria.aggregates = copy.aggregates || this._criteria.aggregates;
|
this._criteria.aggregates = copy.aggregates || this._criteria.aggregates;
|
||||||
|
this._criteria.sorts = copy.sorts || this._criteria.sorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _initSubjectObservables() {
|
protected _initSubjectObservables() {
|
||||||
@ -78,10 +79,10 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
return this.options.transport.commands[name].adapter.handle(command);
|
return this.options.transport.commands[name].adapter.handle(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
query<TQuery extends IQueryCriteria>(query: TQuery) : Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>> {
|
private _query() : Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>> {
|
||||||
return Observable.create((o: Observer<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>) => {
|
return Observable.create((o: Observer<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>) => {
|
||||||
this._loadingSubject.next(true);
|
this._loadingSubject.next(true);
|
||||||
this.options.transport.query.adapter.handle(query)
|
this.options.transport.query.adapter.handle(this._criteria)
|
||||||
.pipe(
|
.pipe(
|
||||||
finalize(() => {
|
finalize(() => {
|
||||||
o.complete();
|
o.complete();
|
||||||
@ -99,8 +100,18 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query<TQuery extends IQueryCriteria>(query: TQuery) {
|
||||||
|
this._criteria.page = query.page || this._criteria.page;
|
||||||
|
this._criteria.pageSize = query.pageSize || this._criteria.pageSize;
|
||||||
|
this._criteria.filters = query.filters || this._criteria.filters;
|
||||||
|
this._criteria.groups = query.groups || this._criteria.groups;
|
||||||
|
this._criteria.aggregates = query.aggregates || this._criteria.aggregates;
|
||||||
|
this._criteria.sorts = query.sorts || this._criteria.sorts;
|
||||||
|
return this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
return this.query(this._criteria).subscribe(
|
return this._query().subscribe(
|
||||||
res => {},
|
res => {},
|
||||||
err => {}
|
err => {}
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,8 @@ export interface IDataSource<TModel>
|
|||||||
{
|
{
|
||||||
resolveCommandModelByName<T extends any>(event: IResolveCommandModelEvent<TModel>) : Observable<T>;
|
resolveCommandModelByName<T extends any>(event: IResolveCommandModelEvent<TModel>) : Observable<T>;
|
||||||
executeCommandByName<TCommand, TResult>(name: string, command: TCommand) : Observable<TResult>;
|
executeCommandByName<TCommand, TResult>(name: string, command: TCommand) : Observable<TResult>;
|
||||||
query<TQuery extends IQueryCriteria>(query: TQuery) : Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
query<TQuery extends IQueryCriteria>(query: TQuery);
|
||||||
|
refresh();
|
||||||
|
|
||||||
data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
||||||
loading$: Observable<boolean>;
|
loading$: Observable<boolean>;
|
||||||
|
Loading…
Reference in New Issue
Block a user