You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are actually no event naming convention in Dahu Next and there is a confusion between event and commands.
For better maintainability and readability it is mandatory to introduce a naming convention and apply this convention (this include refactoring the previous events).
The proposed convention is given below.
We use 'Backbone.Wreqr' for handling message passing within Dahu. This extension to backbone reuse backbone event and introduce two new concepts: command and request&answer (see: https://github.com/marionettejs/backbone.wreqr)
Events:
::= ":"
::= | ":"
::=
::=
For use past-tense only when appropriate.
Let's assume that our handler named as onClicked. Since the handler's name saying in past tense we can get a reasonable question: "When clicked, how long ago it happened? How many times it was clicked? Hmm, maybe it's too late to handle this action (or actions?) at all...". So this name tells us that something happened sometime in past.
In contrast when our handler named as onClick it's obviously that click event just fired and fired once and we was notified about it immediately. And we're going to handle the click event - the information saying us that the state of mouse changed right now (not mouse clicked, but the event of click).
So the names in past tense are more appropriate for the cases when we need to check if some state has been changed or not. E.g. if the variable stores the state = 1 we can call the function isStateChanged(); which will compare the value in state variable with the real value at the current moment. And here the past tense is good choice for naming. (http://stackoverflow.com/a/11990334)
Commands:
::= ":"
Handlers:
::= "on" |
::=
::=
Note: part of the event-name / command-name namespace can be omitted in the resulting handler-name when the module (in which handlers are defined) is in charge of all events / commands from this namespace.
Examples:
Event Name
Handler Name
'kernel:keyboard:keyRelease'
onKeyRelease()
'app:screencast:cleanComplete'
onScreencastCleanComplete()
Command Name
Handler Name
'app:workspace:openNote'
openNote()
'app:previewScreencast'
previewScreencast()
'app:activateFullscreenMode'
activateFullScreenMode()
Wrongs:
'app:onCaptureStop' instead use 'app:stopCapture' 'app:onProjectSave' instead use 'app:saveProject'
The text was updated successfully, but these errors were encountered:
There are actually no event naming convention in Dahu Next and there is a confusion between event and commands.
For better maintainability and readability it is mandatory to introduce a naming convention and apply this convention (this include refactoring the previous events).
The proposed convention is given below.
We use 'Backbone.Wreqr' for handling message passing within Dahu. This extension to backbone reuse backbone event and introduce two new concepts: command and request&answer (see: https://github.com/marionettejs/backbone.wreqr)
Events:
For use past-tense only when appropriate.
Commands:
Handlers:
Note: part of the
event-name
/command-name
namespace can be omitted in the resultinghandler-name
when the module (in which handlers are defined) is in charge of all events / commands from this namespace.Examples:
Wrongs:
'app:onCaptureStop'instead use 'app:stopCapture''app:onProjectSave'instead use 'app:saveProject'The text was updated successfully, but these errors were encountered: