Skip to content

Replace on_trait_change with observe #732

@corranwebster

Description

@corranwebster

The new Traits observe framework has a number of advantages and bugfixes compared to the older on_trait_change listeners. We should migrate the codebase to use the new framework wherever possible.

Because function signatures of observers are different from trait change handlers, we can't make the change in a completely automated way. As a result it is best if we do this in a series of steps to make review easier.

Further, to reduce errors and boilerplate, it makes sense to introduce standard ways to connect and disconnect dynamic observers (for example, via flagging standard metadata).

  • standard framework for connecting/disconnecting observers (Widget observer framework #733)
  • convert all @on_trait_change usages to @observe (about 50 places it is used) (Convert on_trait_change decorators to observe decorators #864)
  • convert all dynamic on_trait_change usages to observe (about 200 places it is used)
    • convert dynamic on_trait_change usages that fit into standard framework
    • convert any other simple (ie. single-trait) on_trait_change usages
    • convert any remaining complex (eg. multiply chained, container) on_trait_change usages

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions