Skip to content

Commit 457af83

Browse files
author
Jeroen van der Heijden
committed
Fix issue #12
1 parent 8fe9b8e commit 457af83

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

thingsdb/model/emitter.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,32 @@ class Emitter(Events):
99
_ev_handlers = dict()
1010

1111
def __init__(self, client: Client, emitter: str = '', scope: str = None):
12+
"""Initializes an emitter.
13+
14+
Args:
15+
client (thingsdb.client.Client):
16+
ThingsDB Client instance.
17+
emitter (str):
18+
Code which should point to the `thing` to watch for events.
19+
Defaults to an empty string which is the collection.
20+
Examples are:
21+
- ''
22+
- '.emitter'
23+
- '#123'
24+
scope (str):
25+
Collection scope. Defaults to the scope of the client.
26+
"""
1227
super().__init__()
1328
self._event_id = 0
1429
self._client = client
1530
self._thing_id = None
1631
self._scope = scope or client.get_scope()
32+
if emitter == '.':
33+
emitter = ''
34+
if emitter:
35+
emitter = f'{{{emitter}}}'
1736
self._code = \
18-
f'{{{emitter}}}.watch(); {{{emitter}}}.id();'
37+
f'{emitter}.watch(); {emitter}.id();'
1938
client.add_event_handler(self)
2039
asyncio.ensure_future(self._watch())
2140

thingsdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.6.9'
1+
__version__ = '0.6.10'

0 commit comments

Comments
 (0)