Skip to content

Commit

Permalink
feat: add request argument to model-api getData method (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-bassett authored Dec 12, 2023
1 parent 0cfa9c3 commit 6e5f249
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/data/data-source/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const dataSourceMarker = Symbol('Data Source Marker');
/**
* A model which can be used to retrieve data asynchronously
*/
export interface DataSource<T> {
export interface DataSource<T, R = unknown> {
/**
* Retrieves data of type T in the form of an observable
*/
getData(): Observable<T>;
getData(request?: R): Observable<T>;

/**
* A marker property used to determine if the implementing class is
Expand Down
4 changes: 2 additions & 2 deletions src/model/api/default-model-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DefaultModelApi implements ModelApi {
/**
* @inheritdoc
*/
public getData<T>(): Observable<T> {
public getData<T, R>(request?: R): Observable<T> {
const dataSource = this.dataSourceManager.getClosest<T>(this.model);

if (!dataSource) {
Expand All @@ -78,7 +78,7 @@ export class DefaultModelApi implements ModelApi {
return EMPTY;
}

return dataSource.getData();
return dataSource.getData(request);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/model/api/model-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface ModelApi {
* attached to)
* - Else, recurse upwards to parent
*/
getData<T>(): Observable<T>;
getData<T, R = unknown>(request?: R): Observable<T>;

/**
* Retrieves the merged theme specified for this model
Expand Down

0 comments on commit 6e5f249

Please sign in to comment.