Skip to content

Commit ccd578b

Browse files
committed
rename StateDispatcher to ViewDispatcher
1 parent ea2297e commit ccd578b

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

docs/source/core-concepts.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ callback that's called by the dispatcher to events it should execute.
127127

128128
import asyncio
129129

130-
from idom.core import SingleStateDispatcher, EventHandler
130+
from idom.core import SingleViewDispatcher, EventHandler
131131
from idom.core.layout import LayoutEvent
132132

133133

@@ -152,7 +152,7 @@ callback that's called by the dispatcher to events it should execute.
152152
return event
153153

154154

155-
async with SingleStateDispatcher(idom.Layout(ClickCount())) as dispatcher:
155+
async with SingleViewDispatcher(idom.Layout(ClickCount())) as dispatcher:
156156
context = None # see note below
157157
await dispatcher.run(send, recv, context)
158158

@@ -163,8 +163,8 @@ callback that's called by the dispatcher to events it should execute.
163163

164164
``context`` is information that's specific to the
165165
:class:`~idom.core.dispatcher.AbstractDispatcher` implementation. In the case of
166-
the :class:`~idom.core.dispatcher.SingleStateDispatcher` it doesn't require any
167-
context. On the other hand the :class:`~idom.core.dispatcher.SharedStateDispatcher`
166+
the :class:`~idom.core.dispatcher.SingleViewDispatcher` it doesn't require any
167+
context. On the other hand the :class:`~idom.core.dispatcher.SharedViewDispatcher`
168168
requires a client ID as its piece of contextual information.
169169

170170

idom/core/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .element import element, Element, AbstractElement, ElementConstructor
22
from .events import event, Events, EventHandler
33
from .layout import Layout, Layout
4-
from .dispatcher import AbstractDispatcher, SharedStateDispatcher, SingleStateDispatcher
4+
from .dispatcher import AbstractDispatcher, SharedViewDispatcher, SingleViewDispatcher
55
from .vdom import vdom
66

77
__all__ = [
@@ -17,6 +17,6 @@
1717
"hooks",
1818
"Layout",
1919
"vdom",
20-
"SharedStateDispatcher",
21-
"SingleStateDispatcher",
20+
"SharedViewDispatcher",
21+
"SingleViewDispatcher",
2222
]

idom/core/dispatcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ async def _incoming(self, layout: Layout, context: Any, message: Any) -> None:
6363
...
6464

6565

66-
class SingleStateDispatcher(AbstractDispatcher):
66+
class SingleViewDispatcher(AbstractDispatcher):
6767
"""Each client of the dispatcher will get its own model.
6868
6969
..note::
70-
The ``context`` parameter of :meth:`SingleStateDispatcher.run` should just
70+
The ``context`` parameter of :meth:`SingleViewDispatcher.run` should just
7171
be ``None`` since it's not used.
7272
"""
7373

@@ -85,11 +85,11 @@ async def _incoming(self, layout: Layout, context: Any, event: LayoutEvent) -> N
8585
return None
8686

8787

88-
class SharedStateDispatcher(SingleStateDispatcher):
88+
class SharedViewDispatcher(SingleViewDispatcher):
8989
"""Each client of the dispatcher shares the same model.
9090
9191
The client's ID is indicated by the ``context`` argument of
92-
:meth:`SharedStateDispatcher.run`
92+
:meth:`SharedViewDispatcher.run`
9393
"""
9494

9595
__slots__ = "_update_queues", "_model_state"

idom/server/sanic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from websockets import WebSocketCommonProtocol
1111

1212
from idom.core.dispatcher import (
13-
SingleStateDispatcher,
14-
SharedStateDispatcher,
13+
SingleViewDispatcher,
14+
SharedViewDispatcher,
1515
SendCoroutine,
1616
RecvCoroutine,
1717
)
@@ -139,7 +139,7 @@ def _run_application(
139139
class PerClientStateServer(SanicRenderServer):
140140
"""Each client view will have its own state."""
141141

142-
_dispatcher_type = SingleStateDispatcher
142+
_dispatcher_type = SingleViewDispatcher
143143

144144
async def _run_dispatcher(
145145
self,
@@ -155,8 +155,8 @@ async def _run_dispatcher(
155155
class SharedClientStateServer(SanicRenderServer):
156156
"""All connected client views will have shared state."""
157157

158-
_dispatcher_type = SharedStateDispatcher
159-
_dispatcher: SharedStateDispatcher
158+
_dispatcher_type = SharedViewDispatcher
159+
_dispatcher: SharedViewDispatcher
160160

161161
def _setup_application(self, app: Sanic, config: Config) -> None:
162162
app.listener("before_server_start")(self._activate_dispatcher)
@@ -166,7 +166,7 @@ def _setup_application(self, app: Sanic, config: Config) -> None:
166166
async def _activate_dispatcher(
167167
self, app: Sanic, loop: asyncio.AbstractEventLoop
168168
) -> None:
169-
self._dispatcher = cast(SharedStateDispatcher, self._make_dispatcher({}, loop))
169+
self._dispatcher = cast(SharedViewDispatcher, self._make_dispatcher({}, loop))
170170
await self._dispatcher.__aenter__()
171171

172172
async def _deactivate_dispatcher(

tests/test_core/test_dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import idom
88
from idom.core.layout import Layout, LayoutEvent
9-
from idom.core.dispatcher import SharedStateDispatcher, AbstractDispatcher
9+
from idom.core.dispatcher import SharedViewDispatcher, AbstractDispatcher
1010

1111

1212
async def test_shared_state_dispatcher():
@@ -45,7 +45,7 @@ async def an_event():
4545

4646
return idom.html.div({"anEvent": an_event, "count": count})
4747

48-
async with SharedStateDispatcher(Layout(Clickable())) as dispatcher:
48+
async with SharedViewDispatcher(Layout(Clickable())) as dispatcher:
4949
await dispatcher.run(send_1, recv_1, "1")
5050
await dispatcher.run(send_2, recv_2, "2")
5151

0 commit comments

Comments
 (0)