README.md in reactor-0.16.1 vs README.md in reactor-0.17.0
- old
+ new
@@ -62,16 +62,23 @@
end
publishes :reminder_sent, at: :reminder_email_time, watch: :created_at
```
- Scheduled events can check conditionally fire -- eg: in 2 days fire reminder_email if the user hasn't already responded.
+ Scheduled events can check conditionally fire -- eg: in 2 days fire reminder_email if the user hasn't already responded. Note that this check will occur at the time the event is intended to fire, after which the state of the model may have changed.
```ruby
publishes :reminder_sent, at: :reminder_email_time, if: -> { user.responded == false }
```
+ It is also possible to conditionally trigger events so that the check happens within the context of the model, at the moment an update occurs, rather than later in the context of the Reactor::Event
+
+```ruby
+publishes :model_changed_in_some_important_way, enqueue_if: -> { important_change_occurred? }
+```
+
+
#### Subscribable
You can now bind any block to an event in your models like so
```ruby
@@ -231,9 +238,23 @@
# stuff
end
```
for your testing convenience.
+
+#### Matchers
+
+You can clean up some event assertions with these somewhat imperfect matchers.
+
+```
+# DRY up strict event & data assertions.
+expect { some_thing }.to publish_event(:some_event, actor: this_user, target: this_object)
+```
+
+```
+# DRY up multi-event assertions. Unfortunately can't test key-values with this at the moment.
+expect { some_thing }.to publish_events(:some_event, :another_event)
+```
### Production Deployments
TLDR; Everything is a Sidekiq::Job, so all the same gotchas apply with regard to removing & renaming jobs that may have a live reference sitting in the queue. (AKA, you'll start seeing 'const undefined' exceptions when the job gets picked up if you've already deleted/renamed the job code.)