Skip to main content

A package for event-driven paradigm

Project description

Package Events++

Classes

Events

This class is runtime created and its purpose is to be inhereted by the event-driven target class. It has the following structure:

class Events:
    def _event1(...):
        # Implementation...

    @property
    def event1(self):
        return self._event1

    @event1.setter
    def event1(self, value):
        self._event1 = EventManager.make_event(value)

    def _event2(...):
        # Implementation...

    @property
    def event2(self):
        return self._event1

    @event2.setter
    def event1(self, value):
        self._event2 = EventManager.make_event(value)

    ...

EventManager

This class builds the Events class, which must be inherited by the event-driven target class. Its implementation is omitted in this tutorial for it is not relevant for the package usage.

event_driven function

This function gets events names-docstring tuples as attributes, creates an EventManager instance and returns an Events class ready to be inherited.

Example:

events_class = event_driven(
                    ('event1', '...'),
                    ('event2', '...'),
                    ('event3', '...'),
                    ...
                )

Usage example

class TargetClass(event_driven(('event1', '...'), ('event2', '...'))):
    __slots__ = 'baa', 'foo'

    def __init__(self):
        # Implementation...

    def foo_maker(self, value):
        self.baa = self.event2(baa)
        self.foo = self.event1(value, self.baa)

When an event is declared, it is created as None, so that nothing will happen during the execution of self.event2, nor self.event1(value, self.baa). Furthermore, even though None is not callable, when an event is None, it is simply not called, no exception is called.

target_instance = TargetClass()

@target_instance.set_event1
def new_event1(self, *args):
    # Implementation...

@target_instance.set_event2
def new_event2(self, baa):
    # Implementation...

Those lines would change event1 and event2 behaviour for target_instance. Although it is not a rule, it is undoubtedly a good habit to use docstring to events for the TargetClass implementation probably expects event1 and event2 to have specific arguments, or none.

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

EventsPP-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

EventsPP-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file EventsPP-0.0.3.tar.gz.

File metadata

  • Download URL: EventsPP-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.2

File hashes

Hashes for EventsPP-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c9de363ffa383a2ef4ba52ef7a6305f2aff559129e7c5b237e9f6c0bc59fb600
MD5 cbe65aaab3ffd0557c106c680be4b57f
BLAKE2b-256 8a93ae7f99766e13276ece3033ca1dfdd558557557c911fdab7362c1f47f1440

See more details on using hashes here.

File details

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

File metadata

  • Download URL: EventsPP-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.2

File hashes

Hashes for EventsPP-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 34added0f7f629d3da416e72966a54ba42656c11c5e30cf7de660e7eab51aa92
MD5 5cc4df9db9506d124845dda32c5cc360
BLAKE2b-256 9fd4b10d0f3ca9f788a5bbbbcecf3f03774a1befd2cbfcf2424faa6b196e8982

See more details on using hashes here.

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