(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))
(vlr-command-reactor nil '((:vlr-commandFailed . failedCommand)))
Ok, first things first:
1. you do not need to have for every event the call of vlr-command-reactor, you simple make a single call and use a list of events calls.... like:
(vlr-command-reactor
nil
'((:vlr-commandWillStart . startCommand)
(:vlr-commandEnded . endCommand)
(:vlr-commandCancelled . cancelCommand)
(:vlr-commandFailed . failedCommand)))
2. The way you are handling your statement is not a good practice, first the vlr-command-reactor function returns a reactor value, that you can pass into a variable where you can have a control of it, in this case not.
3. The use of NIL argument also in many cases is not good practice, and is worst when someone is in the first tries on reactors, it is better to always pass a different value like a string, where later you can localize it like "My MVIEW reactor made by me!".
4. Read about "VLR-EDITOR-REACTOR", and begin using that instead.
5. Here are some functions that might be useful for you:
(defun has-reactor? (obj)
(vl-some
(function (lambda (x) (numberp x)))
(mapcar (function (lambda (r) (vl-position obj (vlr-owners r))))
(cdar (vlr-reactors :vlr-object-reactor)))))
(defun what-reactor? (obj)
(vl-remove-if-not
(function (lambda (r)
(if (vl-position obj (vlr-owners r))
r)))
(cdar (vlr-reactors :vlr-object-reactor))))
;; (attached-to obj)
;; return a list with the list of reactors or nil
(defun attached-to (obj)
(vl-remove
nil
(mapcar
(function
(lambda (reactor-type)
(vl-remove-if-not
(function
(lambda (r)
(cond
((and (equal reactor-type :vlr-object-reactor)
(vl-position obj (vlr-owners r)))
r)
((and
(not (equal reactor-type
:vlr-object-reactor))
(vl-position obj (vlr-data r)))
r))))
(cdar (vlr-reactors reactor-type)))))
(vlr-types))))
;;; verifies if an object is part of a reactor
;;; note: works only with object reactors type
(defun partOf (obj / reactors)
(if (setq reactors (cdar (vlr-reactors :vlr-object-reactor)))
(vl-some
(function (lambda (num) (numberp num)))
(mapcar
(function
(lambda (reactor) (vl-position obj (vlr-owners reactor))))
reactors))))
;;; obtain a list of matching reactions
;;; (get-match-reaction
;;; '(:vlr-modified . calloutsym0-poly-modified-reactor)
;;; :vlr-object-reactor)
(defun get-match-reaction (reaction reactor_type)
(vl-remove-if-not
(function (lambda (reactor)
(vl-position
reaction
(vlr-reactions reactor))))
(cdar (vlr-reactors reactor_type))))
;;; obtain a list of reactions per reactor type
;;; (reactions-perType :vlr-object-reactor)
(defun reactions-perType (reactor_type)
(apply
'append
(mapcar 'vlr-reactions
(cdar (vlr-reactors reactor_type)))))
;;; removes an object from the list of owners of an object reactor
(defun remove-obj-from-reactor (obj)
(foreach reactor (cdar (vlr-reactors :vlr-object-reactor))
(vlr-owner-remove reactor obj)))
;;; get all the present reactors
(defun reactors-present ()
(apply 'append (mapcar 'cdr (vlr-reactors))))
;;; verifies if all the reactors in the list are disabled
(defun are-all-disabled (reactors)
(vl-every (function (lambda (r) (not (vlr-added-p r))))
reactors))
;;; enables all reactors in the list
(defun enable-all (reactors)
;; are all disabled?
(if (and (vl-consp reactors) (are-all-disabled reactors))
;; then enables all
(mapcar 'vlr-add reactors)))
;;; turn a reactor nil
(defun kill-reactor (reactor)
;; only if is a reactor and also is enabled
(if (isReactor reactor)
;;(and (isReactor reactor) (vlr-added-p reactor))
(progn
;; remove the reactor
(vlr-remove reactor)
;; turn it nil or' released
(setq reactor nil))))
;;; set notification for the reactor in his own protected namespace
(defun set-notification (reactor)
;; before the notification make sure is a reactor and is enabled
(if (and (isReactor reactor) (vlr-added-p reactor))
;; now do the notification just in the current active document
(vlr-set-notification
reactor
'active-document-only)))
Have fun!