I have seen these events sprinkled throughout chaplin example code, but there are no explanations within the documentation or the source. It seems that it means it is a global event, that triggers an action. Is that correct? Are they just a convention, or are they enforced in some way?
# Handle login
@subscribeEvent 'logout', @logout
@subscribeEvent 'userData', @userData
# Handler events which trigger an action
# Show the login dialog
@subscribeEvent '!showLogin', @showLoginView
# Try to login with a service provider
@subscribeEvent '!login', @triggerLogin
# Initiate logout
@subscribeEvent '!logout', @triggerLogout
Quoted from a GitHub issue regarding the same question:
!logout
is more a inter-module message or command. It allows one module to trigger the logout (for example a view with a logout button). The actual logout process is then handled by another module (for example the session controller). This module invalidates the session on the server, for example. When successful, it emits alogout
event which means thelogout
has happened. All modules which are interested in login/logout should subscribe tologout
.
I think that explains it pretty well. Basically the !
event is triggered when the action is initiated, and the normal event is triggered when the action was successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With