Add delete library functionality

More reactivity
This commit is contained in:
aditya.chandel
2024-12-20 18:32:41 -07:00
parent e175a7e255
commit 36c85bfb06
24 changed files with 284 additions and 248 deletions
+5 -9
View File
@@ -1,8 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {LibraryService} from './book/service/library.service';
import {RxStompService} from './rx-stomp.service';
import {Message} from '@stomp/stompjs';
import {BookService} from './book/service/book.service';
import {LibraryAndBookService} from './book/service/library-and-book.service';
import {Book} from './book/model/book.model';
@Component({
@@ -13,17 +12,14 @@ import {Book} from './book/model/book.model';
})
export class AppComponent implements OnInit {
constructor(private libraryService: LibraryService, private bookService: BookService, private rxStompService: RxStompService) {
constructor(private libraryBookService: LibraryAndBookService, private rxStompService: RxStompService) {
}
ngOnInit(): void {
this.libraryService.initializeLibraries();
this.bookService.loadBooksSignal(1);
this.libraryBookService.initializeLibraries();
this.rxStompService.watch('/topic/books').subscribe((message: Message) => {
const book: Book = JSON.parse(message.body); // Parse the incoming message to book DTO
this.bookService.appendBookToLibrary(book); // Call method to append to libraryBooks
const book: Book = JSON.parse(message.body);
this.libraryBookService.handleNewBook(book);
});
}