-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Omnes::Bus#performing_only
and remove #with_subscriptions
The new method `#performing_only` runs a given code block with only the given subscriptions. Once the block is over, all previous subscriptions are restored. It plays well with `Omnes` as an including module, as the old `#with_subscriptions` wasn't useful in that context (call to `#initialize`, which is something we don't control). ```ruby creation_subscription = bus.subscribe(:order_created, OrderCreationEmailSubscriber.new) deletion_subscription = bus.subscribe(:order_deleted, OrderDeletionSubscriber.new) bus.performing_only(creation_subscription) do bus.publish(:order_created, number: order.number, user_email: user.email) # `creation_subscription` will run bus.publish(:order_deleted, number: order.number) # `deletion_subscription` won't run end bus.publish(:order_deleted, number: order.number) # `deletion_subscription` will run ```
- Loading branch information
1 parent
9ae6ace
commit 0c8dc16
Showing
4 changed files
with
114 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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