Skip to content

Commit

Permalink
Merge pull request #1 from Apaq/add-observable-repo
Browse files Browse the repository at this point in the history
Added ObservableCrudRepository.
  • Loading branch information
Sina Nejadbakhtiari authored Jun 6, 2023
2 parents 29b1b32 + 5445394 commit 79bd98b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
],
"devDependencies": {
"esbuild": "^0.12.15",
"load-json-file": "^7.0.1",
"rollup": "^2.52.7",
"rollup-plugin-dts": "^3.0.2",
"rollup-plugin-esbuild": "^4.5.0",
"rollup-plugin-terser": "^7.0.2",
"load-json-file": "^7.0.1",
"write-json-file": "^5.0.0"
"write-json-file": "^5.0.0"
},
"dependencies": {
"rxjs": "^7.8.1",
"typescript": "^4.2.3"
}
}
}
15 changes: 15 additions & 0 deletions src/repository/crud-repository-event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

/**
* Interface for events emitted by ObservableCrudRepository.
*/
export interface CrudRepositoryEvent {
/**
* The type of the event.
*/
type: 'Created' | 'Updated' | 'Deleted';

/**
* The id of the entity changed in the repository.
*/
id: string;
}
12 changes: 12 additions & 0 deletions src/repository/observable-crud-repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Observable } from "rxjs";
import { CrudRepository } from "./crud-repository";
import { CrudRepositoryEvent } from "./crud-repository-event";

/**
* Interface for Oberservable CrudRepositories. Adds changes observable upon the CrudRepository interface.
*/
export interface ObservableCrudRepository<TYPE, IDTYPE> extends CrudRepository<TYPE, IDTYPE> {

changes: Observable<CrudRepositoryEvent>;

}

0 comments on commit 79bd98b

Please sign in to comment.