2019-03-31 17:05:09 +08:00
.. _cmd-emit:
2018-12-17 09:39:33 +08:00
emit - Emit a generic event
2019-01-03 12:10:47 +08:00
===========================
2018-12-17 09:39:33 +08:00
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
emit EVENT_NAME [ARGUMENTS...]
2018-12-18 09:58:24 +08:00
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` emit `` emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Example
2019-01-03 12:10:47 +08:00
-------
2018-12-17 05:08:41 +08:00
The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type.
2018-12-19 11:14:04 +08:00
::
function event_test --on-event test_event
echo event test: $argv
end
emit test_event something
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Notes
2019-01-03 12:10:47 +08:00
-----
2018-12-17 05:08:41 +08:00
Note that events are only sent to the current fish process as there is no way to send events from one fish process to another.