Events
sd-create-event
sd-process-event
sd-subscribe-event
sd-unsubscribe-event
Standard Events
SD-CREATE-EVENT
(sd-create-event event)
- Description:
-
Creates a new event which can be processed to invoke subscribed
functions.
- Parameters:
-
- event {STRING} - the new event name
- Return Value:
-
- event {STRING} - new event if successful
- nil - event already exists
- Example:
-
(sd-create-event "foo-event")
SD-PROCESS-EVENT [function]
(sd-process-event event arguments)
- Description:
-
Invokes all functions subscribed to the event.
- Parameters:
-
- event {STRING} - the event name
- arguments {LISP forms} - any number of arguments to be
passed to all functions subscribed to event
- Return Value:
-
- nil - always
- Example:
-
(sd-process-event "foo-event" 12.5 '("string1" "string2"))
SD-SUBSCRIBE-EVENT [function]
(sd-subscribe-event event function arguments)
- Description:
-
Subscribes a function to be invoked when the event is processed.
- Parameters:
-
- event {STRING} - the event name
- function {SYMBOL} - The function to subscribe to the
event.
- Note: As a rule, subscribed functions should ALWAYS include
a &rest parameter to handle additional arguments that maybe passed
to the function by sd-process-event.
- arguments {LISP forms} - any number of arguments to be
passed to function when event is processed
- Return Value:
-
- functions {LIST} - a list of functions subscribed to the
event
- Example:
-
(defun foo-func (arg &rest more-args)
(pprint arg)
(when more-args (pprint more-args)))
(sd-subscribe-event "foo-event" 'foo-func 12.5)
(sd-process-event "foo-event" 24.2)
=> 12.5
(24.2)
SD-UNSUBSCRIBE-EVENT [function]
(sd-unsubscribe-event event function)
- Description:
-
Removes a function from the subscription list of an event.
- Parameters:
-
- event {STRING} - the event name
- function {SYMBOL} - the function to unsubscribe
- Return Value:
-
- functions {LIST} - list of functions still subscribed to
the event
- function {SYMBOL} - the specified function if the event
does not exist
Standard Events
The following constants identify standard events which are available for
use. These constants can be used as parameters for the event functions.
© 2024 Parametric
Technology GmbH
(a subsidiary of PTC Inc.), All Rights Reserved |