Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Within the Chaplin js framework, what do the events prefixed with ! mean?

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
like image 319
sethp Avatar asked Oct 04 '22 23:10

sethp


1 Answers

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 a logout event which means the logout has happened. All modules which are interested in login/logout should subscribe to logout.

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.

like image 52
js-coder Avatar answered Oct 10 '22 02:10

js-coder