sách gpt4 ai đã đi

javascript - 在 Chaplin js 框架中,以 ! 为前缀的事件是做什么的?意思?

In lại 作者:搜寻专家 更新时间:2023-11-01 04:18:39 32 4
mua khóa gpt4 Nike

我看到这些事件散布在 chaplin 示例代码中,但在文档或源代码中没有任何解释。似乎这意味着它是一个全局事件,触发了一个 Action 。那是对的吗?它们只是一个惯例,还是以某种方式强制执行?

# 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

1 Câu trả lời

引自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.

我认为这解释得很好。基本上 ! 事件在 Action 开始时触发,普通事件在 Action 成功时触发。

关于javascript - 在 Chaplin js 框架中,以 ! 为前缀的事件是做什么的?意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15008754/

32 4 0
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com