Skip to main content

A Simple Event Bus.

Project description

PandaBus


This library provided a simple event bus.

Using Example


#1:Basic Using(Usable)


from simpleeventbus import bus



# Create to event listener(printb should called after printa)

@bus.listen("print")

def printa(ent):

    print(f"hello from printa")

@bus.listen("print",after="printa")

def printb(ent):

    print(f'hello from printb')







# send event

bus.send("print")

#2:Pro Using


from simpleeventbus import bus, Event





class StaticEvent(Event, static=True):

    msg: str

class DynaEvent(Event, cancelable=True):

    msg:str



# Create to event listener(printb should called after printa,printc)

@bus.listen(StaticEvent)

def printa(ent):

    print(f"{ent.msg} from printa")

@bus.listen(StaticEvent)

def printb(ent):

    print(f"{ent.msg} from printb")

@bus.listen(StaticEvent, after=["printa","printb"])

def printc(ent):

    print(f'{ent.msg} from printc')

@bus.listen(DynaEvent)

def printd(ent):

    print(f"{ent.msg} from printd")

    ent.cancel()

@bus.listen(DynaEvent,after="printd")

def printe(ent):

    print(f"{ent.msg} from printe")







# send event

bus.send(StaticEvent,"hello")

bus.send(DynaEvent,"hello again")

#3:Own Bus?


from simpleeventbus import buses, Bus



bus1 = buses.bus1  # Simplely get a own bus.

bus2 = Bus("bus2")  # Work too.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pandabus-0.0.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file pandabus-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pandabus-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for pandabus-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c7fb2fd8547c90a17942088ea07f63b9215a192c92935de4b237c1d4fa35d637
MD5 37bf0c3eb2b0ed7ee03fb1432d1309c7
BLAKE2b-256 2d7545a9f89e023b208f5567508fcb86ac2fed109ec91bbe93732b644905ad5a

See more details on using hashes here.

Supported by

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