ephaptic 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ephaptic/client/client.py CHANGED
@@ -3,7 +3,7 @@ import msgpack
3
3
  import websockets
4
4
  import logging
5
5
 
6
- from typing import Callable, Any
6
+ from typing import Callable, Any, Optional
7
7
  import inspect
8
8
 
9
9
  class EphapticClient:
@@ -67,21 +67,29 @@ class EphapticClient:
67
67
  except Exception as e:
68
68
  logging.error(f"Connection error: {e}")
69
69
 
70
- def on(self, event_name, func):
71
- if event_name not in self._event_handlers: self._event_handlers[event_name] = set()
72
- self._event_handlers[event_name].add(func)
70
+ def on(self, event_name, func: Optional[Callable] = None):
71
+ def decorator(f):
72
+ if event_name not in self._event_handlers: self._event_handlers[event_name] = set()
73
+ self._event_handlers[event_name].add(func)
74
+ return f
75
+
76
+ return decorator(func) if func else decorator
73
77
 
74
- def off(self, event_name, func):
78
+ def off(self, event_name, func: Callable):
75
79
  if event_name not in self._event_handlers: return
76
80
  s = self._event_handlers[event_name]
77
81
  s.discard(func)
78
82
  if not s: del self._event_handlers[event_name]
79
83
 
80
- def once(self, event_name, func):
81
- async def wrapper(*args, **kwargs):
82
- self.off(event_name, wrapper)
83
- func(*args, **kwargs)
84
- self.on(event_name, wrapper)
84
+ def once(self, event_name, func: Optional[Callable] = None):
85
+ def decorator(f):
86
+ async def wrapper(*args, **kwargs):
87
+ self.off(event_name, wrapper)
88
+ func(*args, **kwargs)
89
+ self.on(event_name, wrapper)
90
+ return f
91
+
92
+ return decorator(func) if func else decorator
85
93
 
86
94
  def __getattr__(self, name):
87
95
  async def remote_call(*args, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ephaptic
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: The Python client/server package for ephaptic.
5
5
  Author-email: uukelele <robustrobot11@gmail.com>
6
6
  License: MIT License
@@ -5,12 +5,12 @@ ephaptic/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
5
5
  ephaptic/adapters/fastapi_.py,sha256=yfSbJuA7Tgeh9EhZkfIve0Uj-cOZmTBljlBsCRKh2EE,1007
6
6
  ephaptic/adapters/quart_.py,sha256=MBo9g6h_zI63mL4aGdrvV5yEXsHaOd0Iv5J8SAPHBoA,537
7
7
  ephaptic/client/__init__.py,sha256=NeaPIzTFeozP54wlDYHIg_adHP3Z3LWVujsRUlpn4_U,35
8
- ephaptic/client/client.py,sha256=nM54QgdD55w2J5wEWRjOogJQEE5_XmACrWKdikpNvZM,3863
8
+ ephaptic/client/client.py,sha256=YYAlzA40xBvWsiDu0Gsd1EBJaqivLR-bSszepWdNODs,4181
9
9
  ephaptic/transports/__init__.py,sha256=kSAlgvm8sV9nHHu61LTjjTpv4bweah90xvFrwQMDQtQ,169
10
10
  ephaptic/transports/fastapi_ws.py,sha256=X0PMRcwM-KDpKA-zXShGTFhD1kHMSqrx3PBBKZtQ1W0,258
11
11
  ephaptic/transports/websocket.py,sha256=jwgclSDSq0lQCvgwjwUXe9MzPk7NH0FdmsLhWxYBh-4,261
12
- ephaptic-0.1.2.dist-info/licenses/LICENSE,sha256=kMpJjLKMj6zsAhf4uHApO4q0r31Ye1VyfBOl9cFW13M,1065
13
- ephaptic-0.1.2.dist-info/METADATA,sha256=2EQDHLNHOnuyiVXOeY53u-HycxtfpcvrAw9ofP-vLdo,6263
14
- ephaptic-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- ephaptic-0.1.2.dist-info/top_level.txt,sha256=nNhdhcz2o_IuwZ9I2uWQuLZrRmSW0dQVU3qwGrb35Io,9
16
- ephaptic-0.1.2.dist-info/RECORD,,
12
+ ephaptic-0.1.3.dist-info/licenses/LICENSE,sha256=kMpJjLKMj6zsAhf4uHApO4q0r31Ye1VyfBOl9cFW13M,1065
13
+ ephaptic-0.1.3.dist-info/METADATA,sha256=Qs74Bl4B09bcz1d3UMlCoEgFSd3aDnU4X7uthC25qLg,6263
14
+ ephaptic-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ ephaptic-0.1.3.dist-info/top_level.txt,sha256=nNhdhcz2o_IuwZ9I2uWQuLZrRmSW0dQVU3qwGrb35Io,9
16
+ ephaptic-0.1.3.dist-info/RECORD,,