Skip to content

Latest commit

 

History

History
executable file
·
43 lines (34 loc) · 1.55 KB

README.md

File metadata and controls

executable file
·
43 lines (34 loc) · 1.55 KB

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