Skip to content

Commit

Permalink
Document the '-' pattern for on_trait_change. (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Nov 8, 2021
1 parent c903296 commit 0687f9b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/source/traits_user_manual/listening.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,27 @@ Semantics
| |begins with *prefix* and that does *not* have |
| |a metadata attribute called *metadata_name*. |
+------------------------------+----------------------------------------------+
|``+`` |Matches all traits on the object. |
|``+`` |Matches all traits on the object, via |
| |per-trait notifiers. (See note below.) |
+------------------------------+----------------------------------------------+
|``-`` |Matches all traits on the object, via an |
| |object notifier. (See note below.) |
+------------------------------+----------------------------------------------+
|*pattern*\ * |Matches object graphs where *pattern* occurs |
| |one or more times. This option is useful for |
| |setting up listeners on recursive data |
| |structures like trees or linked lists. |
+------------------------------+----------------------------------------------+

.. note::
The patterns ``"+"`` and ``"-"`` both match all traits on a ``HasTraits``
object. The two patterns behave almost identically, but
there's a difference at the implementation level. The ``"+"`` pattern
registers one trait-level notifier for each trait on the target object,
while the ``"-"`` pattern registers a single *object*-level notifier on the
target object. As a result, the two patterns may have different
performance characteristics.

.. index:: extended trait names; examples

.. _examples-of-extended-name-notation-table:
Expand Down

0 comments on commit 0687f9b

Please sign in to comment.