You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -230,6 +230,8 @@ The function `registerEventListeners` will be called automatically when an insta
230
230
231
231
Our *Callback* (or *Handler* or *Listener Event*) is called `onTemperatureEvent`, which is where we will implement whatever *Operation* is to be performed against a `TemperatureEvent`.
232
232
233
+
Version 5.0.0 introduces the new parameter, `dispatchTime`, which will always provide the `DispatchTime` reference at which the *Event* was *Dispatched*. You can use this to determine *Delta* (how much time has passed since the *Event* was *Dispatched*), which is particularly useful if you are performing interpolation and/or extrapolation.
234
+
233
235
Now, let's actually do something with our `TemperatureEvent` in the `onTemperatureEvent` method.
234
236
```swift
235
237
/// An Enum to map a Temperature value onto a Rating
@@ -262,7 +264,7 @@ Now, let's actually do something with our `TemperatureEvent` in the `onTemperatu
@@ -427,6 +429,30 @@ This will remove your *Listener Callback*, meaning it will no longer be invoked
427
429
428
430
`EventListener`s are an extremely versatile and very powerful addition to `EventDrivenSwift`.
429
431
432
+
## `EventListener` with *Latest-Only* Interest
433
+
Version 4.3.0 of this library introduces the concept of *Latest-Only Listeners*. A *Latest-Only Listener* is a *Listener* that will only be invoked for the very latest *Event* of its requested *Event Type*. If there are a number of older *Events* of this type pending in a Queue/Stack, they will simply be skipped over... and only the very *Latest* will invoke your *Listener*.
434
+
435
+
We have made it incredibly simple for you to configure your *Listener* to be a *Latest-Only Listener*. Taking the previous code example, we can simply modify it as follows:
By including the `interestedIn` optional parameter when invoking `addListener` against any `Eventable` type, and passing for this parameter a value of `.latestOnly`, we define that this *Listener* is only interested in the *Latest*`TemperatureRatingEvent` to be *Dispatched*. Should a number of `TemperatureRatingEvent`s build up in the Queue/Stack, the above-defined *Listener* will simply discard any older Events, and only invoke for the newest.
455
+
430
456
## `EventPool`
431
457
Version 4.0.0 introduces the extremely powerful `EventPool` solution, making it possible to create managed groups of `EventThread`s, where inbound *Events* will be directed to the best `EventThread` in the `EventPool` at any given moment.
432
458
@@ -456,9 +482,8 @@ The above example would use the `EventPoolLowestLoadBalancer` implementation, wh
456
482
## Features Coming Soon
457
483
`EventDrivenSwift` is an evolving and ever-improving Library, so here are lists of the features you can expect in future releases.
458
484
459
-
Version 4.3.0 (or 5.0.0 if interface-breaking changes are required):
460
-
-**Event Pool Scalers** - Dynamic Scaling for `EventPool` instances will be fully-implemented
461
-
-**Latest-Only Events** - A Dispatch option to replace any unprocessed (older) *Events* with the newest *Event* of that specific *Eventable* type. This will be useful for things like sensor readings, where you only care about the most recent value possible (because older values are no longer relevant)
485
+
Version 5.1.0 (or 6.0.0 if interface-breaking changes are required):
486
+
-**Event Pool Scalers** - Dynamic Scaling for `EventPool` instances will be fully-implemented (for the moment, no automatic Scaling will occur, and you cannot change the scale of an *Event Pool* once it has been initialised)
@@ -102,6 +102,7 @@ open class EventDispatcher: EventHandler, EventDispatching {
102
102
if receiver.receiver ==nil{ /// If the Recevier is `nil`...
103
103
continue
104
104
}
105
+
if receiver.receiver!.interestedIn ==.latestOnly && event.dispatchTime <latestEventDispatchTime[event.event.getEventTypeName()]! {continue} // If this Receiver is only interested in the Latest Event dispatched for this Event Type, and this Event is NOT the Latest... skip it!
0 commit comments