{"id":15533403,"url":"https://github.com/nocarryr/python-dispatch","last_synced_at":"2026-03-08T11:39:03.137Z","repository":{"id":10556640,"uuid":"65749909","full_name":"nocarryr/python-dispatch","owner":"nocarryr","description":"Lightweight event handling for Python","archived":false,"fork":false,"pushed_at":"2024-09-03T21:34:06.000Z","size":13029,"stargazers_count":39,"open_issues_count":6,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T00:48:12.503Z","etag":null,"topics":["asyncio","dispatcher","event-dispatcher","events","observer-pattern","python","python-library","signals"],"latest_commit_sha":null,"homepage":"https://python-dispatch.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nocarryr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-15T17:09:38.000Z","updated_at":"2024-08-30T07:38:12.000Z","dependencies_parsed_at":"2024-06-21T07:11:19.793Z","dependency_job_id":"7cd28d15-5a24-4e14-9e83-121e0b7e9d70","html_url":"https://github.com/nocarryr/python-dispatch","commit_stats":{"total_commits":232,"total_committers":1,"mean_commits":232.0,"dds":0.0,"last_synced_commit":"9d14db21d015c509bc41fb5cde53a9dffb137cca"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nocarryr%2Fpython-dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nocarryr%2Fpython-dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nocarryr%2Fpython-dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nocarryr%2Fpython-dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nocarryr","download_url":"https://codeload.github.com/nocarryr/python-dispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830952,"owners_count":20354854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","dispatcher","event-dispatcher","events","observer-pattern","python","python-library","signals"],"created_at":"2024-10-02T11:36:42.686Z","updated_at":"2026-03-08T11:39:03.131Z","avatar_url":"https://github.com/nocarryr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-dispatch\nLightweight event handling for Python\n\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/nocarryr/python-dispatch/ci.yml)[![Coverage Status](https://coveralls.io/repos/github/nocarryr/python-dispatch/badge.svg?branch=master)](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[![PyPI version](https://badge.fury.io/py/python-dispatch.svg)](https://badge.fury.io/py/python-dispatch)[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)\n\n## Description\nThis is an implementation of the \"Observer Pattern\" with inspiration from the\n[Kivy](kivy.org) framework. Many of the features though are intentionally\nstripped down and more generalized. The goal is to have a simple drop-in\nlibrary with no dependencies that stays out of the programmer's way.\n\n## Installation\n\"python-dispatch\" is available on [PyPI](https://pypi.org/project/python-dispatch/)\nand can be installed using pip:\n\n```bash\npip install python-dispatch\n```\n\n### Python Requirements\nAfter version `0.1` of this project, only Python 3.6 and above will be supported.\nIf using an older Python version, the older releases should still be available\non PyPI and the correct package should be chosen automatically by `pip`.\nIf not, either upgrade `pip` and `setuptools`:\n\n```bash\npip install -U pip setuptools\n```\n\nOr specify the version manually:\n\n```bash\npip install python-dispatch\u003c0.2\n```\n\n## Links\n\n|               |                                              |\n| -------------:|:-------------------------------------------- |\n| Project Home  | https://github.com/nocarryr/python-dispatch  |\n| PyPI          | https://pypi.python.org/pypi/python-dispatch |\n| Documentation | https://python-dispatch.readthedocs.io       |\n\n\n## Usage\n\n### Events\n\n```python\n\u003e\u003e\u003e from pydispatch import Dispatcher\n\n\u003e\u003e\u003e class MyEmitter(Dispatcher):\n...     # Events are defined in classes and subclasses with the '_events_' attribute\n...     _events_ = ['on_state', 'new_data']\n...     def do_some_stuff(self):\n...         # do stuff that makes new data\n...         data = {'foo':'bar'}\n...         # Then emit the change with optional positional and keyword arguments\n...         self.emit('new_data', data=data)\n\n\u003e\u003e\u003e # An observer - could inherit from Dispatcher or any other class\n\u003e\u003e\u003e class MyListener(object):\n...     def on_new_data(self, *args, **kwargs):\n...         data = kwargs.get('data')\n...         print('I got data: {}'.format(data))\n...     def on_emitter_state(self, *args, **kwargs):\n...         print('emitter state changed')\n\n\u003e\u003e\u003e emitter = MyEmitter()\n\u003e\u003e\u003e listener = MyListener()\n\n\u003e\u003e\u003e # Bind to the \"on_state\" and \"new_data\" events of emitter\n\u003e\u003e\u003e emitter.bind(on_state=listener.on_emitter_state)\n\u003e\u003e\u003e emitter.bind(new_data=listener.on_new_data)\n\n\u003e\u003e\u003e emitter.do_some_stuff()\nI got data: {'foo': 'bar'}\n\u003e\u003e\u003e emitter.emit('on_state')\nemitter state changed\n\n```\n\n### Properties\n\n```python\n\u003e\u003e\u003e from pydispatch import Dispatcher, Property\n\n\u003e\u003e\u003e class MyEmitter(Dispatcher):\n...     # Property objects are defined and named at the class level.\n...     # They will become instance attributes that will emit events when their values change\n...     name = Property()\n...     value = Property()\n\n\u003e\u003e\u003e class MyListener(object):\n...     def on_name(self, instance, value, **kwargs):\n...         print('emitter name is {}'.format(value))\n...     def on_value(self, instance, value, **kwargs):\n...         print('emitter value is {}'.format(value))\n\n\u003e\u003e\u003e emitter = MyEmitter()\n\u003e\u003e\u003e listener = MyListener()\n\n\u003e\u003e\u003e # Bind to the \"name\" and \"value\" properties of emitter\n\u003e\u003e\u003e emitter.bind(name=listener.on_name, value=listener.on_value)\n\n\u003e\u003e\u003e # Set emitter.name property (triggering the on_name callback)\n\u003e\u003e\u003e emitter.name = 'foo'\nemitter name is foo\n\n\u003e\u003e\u003e # Set emitter.value (triggering the on_value callback)\n\u003e\u003e\u003e emitter.value = 42\nemitter value is 42\n\n```\n\n## Contributing\n\nContributions are welcome!\n\nIf you want to contribute through code or documentation, please see the\n[Contributing Guide](CONTRIBUTING.md) for information.\n\n## License\n\nThis project is released under the MIT License. See the [LICENSE](LICENSE.txt) file\nfor more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnocarryr%2Fpython-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnocarryr%2Fpython-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnocarryr%2Fpython-dispatch/lists"}