Skip to content

Instantly share code, notes, and snippets.

@alexandre-jacquot-ptl
Last active May 23, 2021 16:39
Show Gist options
  • Save alexandre-jacquot-ptl/57725636df90febe78c50ea5ee638df6 to your computer and use it in GitHub Desktop.
Save alexandre-jacquot-ptl/57725636df90febe78c50ea5ee638df6 to your computer and use it in GitHub Desktop.
r2dbc ItemService events
@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