Skip to main content

funksignal is a signaling library for event-driven programming

Project description

funksignal · GitHub license

funksignal is a synchronous signaling library for event-driven programming. Bind methods to signals which will be executed once the signal is emitted.

How to Install

To install funksignal, open a terminal and use the pip package manager:

   pip install funksignal

Instructions

To use funksignal effectively, bind one or more methods to a signal identified by a unique key. When the signal is emitted, all methods bound to that signal will be executed. If you no longer need the binding, you can simply unbind it.

from funksignal import Signal

def example():
    print("Hello World")

Signal.bind("signal-key", example)
Signal.emit("signal-key")
Signal.unbind("signal-key", example)

funksignal provides an interface to pass arguments – from within bind(), emit() or simultaniously via *args and **kwargs.

from funksignal import Signal

def example(a, b):
    print(f"{a} {b}")

Signal.bind("1a", example)
Signal.emit("1a", "Hello", "World")

Signal.bind("1b", example, "Hello", "World")
Signal.emit("1b")

Signal.bind("2a", example)
Signal.emit("2a", a="Hello", b="World")

Signal.bind("2b", example, a="Hello", b="World")
Signal.emit("2b")

Signal.bind("2c", example, a="Hello")
Signal.emit("2c", b="World")

Documentation

Auto-generated documentation using pydoc-markdown.

bind

@classmethod
def bind(cls, key: Union[str, int], callable: callable, *args: any, **kwargs: any) -> None

Binds a callable to a signal. The callable will be executed when the signal is emitted.

unbind

@classmethod
def unbind(cls, key: Union[str, int], callable: callable) -> None

Unbinds a callable from a signal. After unbinding, the callable will no longer be executed when the signal is emitted.

emit

@classmethod
def emit(cls, key: Union[str, int], *args: any, **kwargs: any) -> None

Emits a signal identified by the given key. This triggers the execution of all callables that are bound to the signal. You can pass arguments to the bound methods via *args and **kwargs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

funksignal-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

funksignal-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file funksignal-0.1.0.tar.gz.

File metadata

  • Download URL: funksignal-0.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for funksignal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6ca0eee3dc635a768e5753841ab0ed345d412ec929e27382c168956d62cca62
MD5 39f13f1bf3bb2291debca0fdec51b4e6
BLAKE2b-256 8931f35bc704ef343a33be7c2cba76a96090d9227d81f09921a1e68535cd4f54

See more details on using hashes here.

Provenance

The following attestation bundles were made for funksignal-0.1.0.tar.gz:

Publisher: publish.yml on Dreamfarer/funksignal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file funksignal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: funksignal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for funksignal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a63bfc82c32f036e44a35ad47d71fdfc15ae8c7494f9fd0b0bd9d7746d40ff61
MD5 fdbb4aab89e9a7ba5dcef4d595f7eb45
BLAKE2b-256 ee71bbd17a51f01b1064f107451b0983560ae3501a72aacea2ae0fa2595ebbf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for funksignal-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Dreamfarer/funksignal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page