Skip to content

Commit

Permalink
firstBook = linkedSignal(() => this.books()[0]);
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesHoppe committed Nov 3, 2024
1 parent ef9f87d commit 6c3a104
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/books/book-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export class BookListComponent {
computation: books => books[0]
});

// this also works (shorthand version)
// firstBook = linkedSignal(() => this.books()[0]);

overrideFirstBook() {
// Manually updating `firstBook`, which now returns 'jQuery'
this.firstBook.set('jQuery');
Expand Down
1 change: 0 additions & 1 deletion src/app/books/book/book.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class BookComponent {
// this also works:
// rating = linkedSignal(() => this.book().rating);


doRateUp() {
const newRating = this.rating() + 1;
this.rating.set(newRating);
Expand Down

0 comments on commit 6c3a104

Please sign in to comment.