Last active
May 23, 2021 16:39
-
-
Save alexandre-jacquot-ptl/57725636df90febe78c50ea5ee638df6 to your computer and use it in GitHub Desktop.
r2dbc ItemService events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@RequiredArgsConstructor | |
public class ItemService { | |
private final NotificationService notificationService; | |
... | |
/** | |
* Listen to all saved items | |
* | |
* @return the saved items | |
*/ | |
public Flux<Item> listenToSavedItems() { | |
return this.notificationService.listen(ITEM_SAVED, Item.class) | |
.flatMap(this::loadRelations); | |
} | |
/** | |
* Listen to all deleted items | |
* | |
* @return the ID of the deleted items | |
*/ | |
public Flux<Long> listenToDeletedItems() { | |
return this.notificationService.listen(ITEM_DELETED, Item.class) | |
.map(Item::getId); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment