The package define an AbstractEvent
interface and provide a few basic implementations.
In particular it implements a flexible CustomEvent
type which can handle several different events.
See FileMTimeEvent
as an example and check the tests for usage.
using EasyEvents
let
@info("Testing PropertyChangedEvent")
# This handler track an object
e = PropertyChangedEvent(Main)
# Initialize the handler state for Main.__glob
global __glob = rand()
update!(e, :__glob)
events_count = 0
trigger_at = [2, 4, 8]
for it in 1:10
# modify Main.__glob
if it in trigger_at
println("[", it, "] changing __glob!!!")
__glob = rand()
end
# This will run if Main.__glob changed from the last update
# The bang indicates that `update!(e, :__glob)` will be called
if pull_event!(e, :__glob)
println("[", it, "] event detected!!!")
else
println("[", it, "] nothing to do!!!")
end
end
end