Skip to content

Commit 897a30c

Browse files
committed
minor doc updates
1 parent b294646 commit 897a30c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

docs/source/core-concepts.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ ever be removed from the model. Then you'll just need to call and await a
6666
async with idom.Layout(ClickCount()) as layout:
6767
patch = await layout.render()
6868

69-
The layout also handles the triggering of event handlers. Normally this is done
70-
automatically by a :ref:`Dispatcher <Layout Dispatcher>`, but for now we'll do it manually.
71-
We can use a trick to hard-code the ``event_handler_id`` so we can pass it, and a fake
72-
event, to the layout's :meth:`~idom.core.layout.Layout.dispatch` method. Then we just
73-
have to re-render the layout and see what changed:
69+
The layout also handles the triggering of event handlers. Normally these are
70+
automatically sent to a :ref:`Dispatcher <Layout Dispatcher>`, but for now we'll do it
71+
manually. To do this we need to pass a fake event with its "target" (event handler
72+
identifier), to the layout's :meth:`~idom.core.layout.Layout.dispatch` method, after
73+
which we can re-render and see what changed:
7474

7575
.. testcode::
7676

@@ -85,10 +85,10 @@ have to re-render the layout and see what changed:
8585
[f"Click count: {count}"],
8686
)
8787

88-
async with idom.Layout(ClickCount(key="something")) as layout:
88+
async with idom.Layout(ClickCount(key="test-component")) as layout:
8989
patch_1 = await layout.render()
9090

91-
fake_event = LayoutEvent("/something/onClick", [{}])
91+
fake_event = LayoutEvent(target="/test-component/onClick", data=[{}])
9292
await layout.dispatch(fake_event)
9393
patch_2 = await layout.render()
9494

@@ -98,6 +98,12 @@ have to re-render the layout and see what changed:
9898

9999
assert count_did_increment
100100

101+
.. note::
102+
103+
Don't worry about the format of the layout event's ``target``. Its an internal
104+
detail of the layout's implementation that is neither neccessary to understanding
105+
how things work, nor is it part of the interface clients should rely on.
106+
101107

102108
Layout Dispatcher
103109
-----------------
@@ -129,7 +135,7 @@ callback that's called by the dispatcher to events it should execute.
129135

130136

131137
async def recv():
132-
event = LayoutEvent("/my-component/onClick", [{}])
138+
event = LayoutEvent(target="/test-component/onClick", data=[{}])
133139

134140
# We need this so we don't flood the render loop with events.
135141
# In practice this is never an issue since events won't arrive
@@ -140,7 +146,7 @@ callback that's called by the dispatcher to events it should execute.
140146

141147

142148
async with SingleViewDispatcher(
143-
idom.Layout(ClickCount(key="my-component"))
149+
idom.Layout(ClickCount(key="test-component"))
144150
) as dispatcher:
145151
context = None # see note below
146152
await dispatcher.run(send, recv, context)

0 commit comments

Comments
 (0)