Sometimes one package wants to do something when an event happens in another package, but they don’t necessarily want to introduce a dependency. I threw together Hooks.jl to make this easy.
For example, say Atom.jl wants to be able to notify other packages when it’s loaded, so it might have:
# Atom.jl
function __init__()
# some initialization code
notify(hook"atom-initialized")
end
Then some other package can take some action
function __init__()
handle(hook"atom-initialized") do
# this is from Revise.jl
setup_atom(getfield(Main, :Atom)::Module)
end
end
Now this initialization will happen regardless of which order Atom and the OtherPkg are loaded in.
Good idea? Terrible idea?