2019-03-31 09:05:09 +00:00
.. _cmd-emit:
2018-12-17 01:39:33 +00:00
emit - Emit a generic event
2019-01-03 04:10:47 +00:00
===========================
2018-12-17 01:39:33 +00:00
2018-12-18 01:58:24 +00:00
Synopsis
--------
2018-12-16 21:08:41 +00:00
2019-09-17 09:59:04 +00:00
::
2018-12-18 01:58:24 +00:00
2019-09-17 09:59:04 +00:00
emit EVENT_NAME [ARGUMENTS...]
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Description
2019-01-03 04:10:47 +00:00
-----------
2018-12-16 21:08:41 +00:00
2019-10-04 13:03:25 +00:00
`` emit `` emits, or fires, an event. Events are delivered to, or caught by, special functions called :ref: `event handlers <event>` . The arguments are passed to the event handlers as function arguments.
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Example
2019-01-03 04:10:47 +00:00
-------
2018-12-16 21:08:41 +00: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 03:14:04 +00:00
::
function event_test --on-event test_event
echo event test: $argv
end
emit test_event something
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Notes
2019-01-03 04:10:47 +00:00
-----
2018-12-16 21:08:41 +00: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.