Library Integration

How to use ictr within a library without interfering with application-level configuration.

Registering Addresses

Libraries should use register_address to configure their own module addresses without interfering with the application’s configuration. The library can set defaults for its modules, which the application can override.

# mylibrary/__init__.py
import ictr

# Register library-specific configuration
ictr.register_address(
    'mylibrary',
    flavors={
        # Custom library flavors or overrides if needed
    }
)

The register_address function is convenient for libraries because:

  • If the application has installed ictr, the library’s configuration is registered with that dispatcher.

  • If the application hasn’t installed ictr, a default dispatcher is created automatically.

  • Either way, the library can emit messages without worrying about whether the application has initialized ictr.

>>> # Library registers its address configuration
>>> config = ictr.register_address( 'mylib' )

>>> # Application uses the dispatcher to emit messages
>>> ictr_app( 'note', address = 'mylib' )( 'Library initialization complete.' )
NOTE|  Library initialization complete.