Skip to content

josePereiro/EasyEvents.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyEvents

Build Status Coverage

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.

Basic 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 has_event!(e, :__glob)
            println("[", it, "] event detected!!!")
        else
            println("[", it, "] nothing to do!!!")
        end
    end
end