Skip to content

Commit

Permalink
minors
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaximum-at-2sic committed Mar 9, 2022
1 parent 8b3aa33 commit d7dd95e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,30 @@ export class Query<T> {
}

/**
* Get an object with the specified streams seperated by comma, each containing an array of all the data in that stream
* Get an object with the specified streams, each containing an array of all the data in that stream
*/
getStreams(streams: string): Observable<T>;
getStreams(streams: string[]): Observable<T>;

/**
* Get an object with the specified streams seperated by comma,
* each containing an array of all the data in that stream with url-parameters as HttpParams
* Get an object with the specified streams, each containing an array of all the data in that stream with url-parameters as HttpParams
*/
getStreams(streams: string, params: HttpParams): Observable<T>;
getStreams(streams: string[], params: HttpParams): Observable<T>;

/**
* Get an object with the specified streams seperated by comma,
* each containing an array of all the data in that stream with url-parameters as string
* Get an object with the specified streams, each containing an array of all the data in that stream with url-parameters as string
*/
getStreams(streams: string, params: string): Observable<T>;
getStreams(streams: string[], params: string): Observable<T>;

/**
* Get an object with the specified streams seperated by comma,
* each containing an array of all the data in that stream with url-parameters as string
* Get an object with the specified streams, each containing an array of all the data in that stream with url-parameters as string
*/
getStreams(streams: string, params: HttpParams | string, data: T): Observable<T>;
getStreams(streams: string[], params: HttpParams | string, data: T): Observable<T>;

/**
* Internal implementation of getStreams
*/
getStreams(streams: string, params: HttpParams | string = null, data: T = null): Observable<T> {
const url = `${routeQuery}/${this.name}?${this.streamParamKey}=${streams}`;
getStreams(streams: string[], params: HttpParams | string = null, data: T = null): Observable<T> {
const url = `${routeQuery}/${this.name}?${this.streamParamKey}=${streams.join(',')}`;

if (data)
return (typeof(params) === 'string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ export class SxcData {
public query$<T>(param1: any, param2?: HttpParams) {
if (typeof param1 === 'object') {
const { name, params, streams } = <QueryConstruction>param1;
return new Query<T>(this.http, name).fetch(params, streams);
} else {
return new Query<T>(this.http, param1).fetch(param2);
}
const query = new Query<T>(this.http, name);
return (Array.isArray(streams) ? query.getStreams(streams, params) : query.getStream(streams, params));
} else return new Query<T>(this.http, param1).getAll();
}


Expand Down Expand Up @@ -99,6 +98,6 @@ export class SxcData {
const method = apiName.substr(separator + 1);
apiName = apiName.substr(0, separator);

return new Api(this.http, apiName).fetch<T>(method, params);
return new Api(this.http, apiName).fetch<T>(method);
}
}

0 comments on commit d7dd95e

Please sign in to comment.