{"id":21872,"library":"rel","title":"Registered Event Listener (rel)","description":"Rel is a lightweight (0.4.9.26) event/observer pattern library for Python that implements the standard pyevent interface without external dependencies. It provides a simple publish-subscribe mechanism with event registration, firing, and listener management. The library is API-stable with infrequent releases.","status":"active","version":"0.4.9.26","language":"python","source_language":"en","source_url":"https://github.com/trustable/REL","tags":["event","observer","listener","publish-subscribe","lightweight"],"install":[{"cmd":"pip install rel","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Direct import of the package.","symbol":"rel","correct":"import rel"},{"note":"EventHandler is a top-level module, not a sub-package.","wrong":"from rel.event import EventHandler","symbol":"EventHandler","correct":"from rel import EventHandler"},{"note":"add is a top-level function to register listeners.","symbol":"add","correct":"from rel import add"},{"note":"fire is a top-level function to trigger events.","symbol":"fire","correct":"from rel import fire"}],"quickstart":{"code":"import rel\n\n# Register an event listener\ndef my_handler(data):\n    print(f\"Received: {data}\")\n\nrel.add('my_event', my_handler)\n\n# Fire an event\nrel.fire('my_event', {'key': 'value'})\n\n# Remove listener\nrel.remove('my_event', my_handler)\n\n# Fire event after 1 second\nrel.fire_in(1.0, 'my_event', 'hello')","lang":"python","description":"Basic usage: add listeners, fire events synchronously or with a delay."},"warnings":[{"fix":"Use rel.timeout or rel.schedule for timed callbacks, not threading.Thread.","message":"The library is single-threaded by default. Do not assume thread safety; use rel's own async/schedule features for concurrent patterns.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace EventHandler instances with rel.add() and rel.fire(). Visit documentation for migration.","message":"EventHandler is deprecated; use the module-level functions (add, fire, remove) instead.","severity":"gotcha","affected_versions":"0.4.x"},{"fix":"Call rel.dispatch() (blocking) to start the event loop after scheduling. Use a non-blocking alternative like rel.timeout if you need async in a GUI framework.","message":"When using rel.fire_in() or rel.schedule(), the program will exit immediately unless rel.dispatch() is running. These methods schedule on an internal timer that only fires while dispatch() is active.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from rel import EventHandler (or simply import rel and use rel.add/fire).","cause":"Attempting to import from rel.event which does not exist as a submodule.","error":"AttributeError: module 'rel' has no attribute 'event'"},{"fix":"Use: from rel import add (or import rel and then rel.add).","cause":"Importing incorrectly: from rel import * does not export add due to __all__ not defined.","error":"NameError: name 'add' is not defined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}