File: man.rst

package info (click to toggle)
pyee 13.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: python: 1,113; makefile: 4; sh: 1
file content (70 lines) | stat: -rw-r--r-- 1,735 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
pyee
====

pyee is a rough port of
`node.js's EventEmitter <https://nodejs.org/api/events.html>`_. Unlike its
namesake, it includes a number of subclasses useful for implementing async
and threaded programming in python, such as async/await as seen in python 3.5+.

Install
-------

You can install this project into your environment of choice using ``pip``::

    pip install pyee

Usage
-----

pyee supplies a ``EventEmitter`` class that is similar to the
``EventEmitter`` class from Node.js. In addition, it supplies subclasses for
``asyncio``, ``twisted``, ``concurrent.futures`` and ``trio``, as supported
by the environment.


Example
-------

::

    In [1]: from pyee.base import EventEmitter

    In [2]: ee = EventEmitter()

    In [3]: @ee.on('event')
       ...: def event_handler():
       ...:     print('BANG BANG')
       ...:

    In [4]: ee.emit('event')
    BANG BANG

    In [5]:


API
---

pyee contains a number of modules, each intended for a different concurrency
paradigm or framework:

- ``pyee`` - synchronous ``EventEmitter``, like Node.js
- ``pyee.asyncio`` - asyncio support
- ``pyee.twisted`` - twisted support
- ``pyee.executor`` - concurrent.futures support
- ``pyee.trio`` - trio support

In addition, it contains two experimental modules:

- ``pyee.uplift`` - support for "uplifting" event emitters from one paradigm
  to another - ie., adopting synchronous event emitters for use with asyncio
- ``pyee.cls`` - support for "evented classes", which call class methods on
  events

For in-depth API documentation, visit `the docs on readthedocs.io <https://pyee.rtfd.io>`_.

Links
-----

* `Fork Me On GitHub! <https://github.com/jfhbrook/pyee>`_
* `The Docs on readthedocs.io <https://pyee.rtfd.io>`_