3838from idom .backend .hooks import ConnectionContext
3939from idom .backend .hooks import use_connection as _use_connection
4040from idom .backend .types import Connection , Location
41- from idom .core .layout import LayoutEvent , LayoutUpdate
42- from idom .core .serve import serve_json_patch
41+ from idom .core .serve import serve_layout
4342from idom .core .types import ComponentType , RootComponentConstructor
4443from idom .utils import Ref
4544
@@ -182,8 +181,8 @@ def model_stream(ws: WebSocket, path: str = "") -> None:
182181 def send (value : Any ) -> None :
183182 ws .send (json .dumps (value ))
184183
185- def recv () -> LayoutEvent :
186- return LayoutEvent ( ** json .loads (ws .receive () ))
184+ def recv () -> Any :
185+ return json .loads (ws .receive ())
187186
188187 _dispatch_in_thread (
189188 ws ,
@@ -203,7 +202,7 @@ def _dispatch_in_thread(
203202 path : str ,
204203 component : ComponentType ,
205204 send : Callable [[Any ], None ],
206- recv : Callable [[], Optional [LayoutEvent ]],
205+ recv : Callable [[], Optional [Any ]],
207206) -> NoReturn :
208207 dispatch_thread_info_created = ThreadEvent ()
209208 dispatch_thread_info_ref : idom .Ref [Optional [_DispatcherThreadInfo ]] = idom .Ref (None )
@@ -213,18 +212,15 @@ def run_dispatcher() -> None:
213212 loop = asyncio .new_event_loop ()
214213 asyncio .set_event_loop (loop )
215214
216- thread_send_queue : "ThreadQueue[LayoutUpdate ]" = ThreadQueue ()
217- async_recv_queue : "AsyncQueue[LayoutEvent ]" = AsyncQueue ()
215+ thread_send_queue : "ThreadQueue[Any ]" = ThreadQueue ()
216+ async_recv_queue : "AsyncQueue[Any ]" = AsyncQueue ()
218217
219218 async def send_coro (value : Any ) -> None :
220219 thread_send_queue .put (value )
221220
222- async def recv_coro () -> Any :
223- return await async_recv_queue .get ()
224-
225221 async def main () -> None :
226222 search = request .query_string .decode ()
227- await serve_json_patch (
223+ await serve_layout (
228224 idom .Layout (
229225 ConnectionContext (
230226 component ,
@@ -239,7 +235,7 @@ async def main() -> None:
239235 ),
240236 ),
241237 send_coro ,
242- recv_coro ,
238+ async_recv_queue . get ,
243239 )
244240
245241 main_future = asyncio .ensure_future (main (), loop = loop )
@@ -282,9 +278,9 @@ def run_send() -> None:
282278
283279class _DispatcherThreadInfo (NamedTuple ):
284280 dispatch_loop : asyncio .AbstractEventLoop
285- dispatch_future : " asyncio.Future[Any]"
286- thread_send_queue : " ThreadQueue[LayoutUpdate]"
287- async_recv_queue : " AsyncQueue[LayoutEvent]"
281+ dispatch_future : asyncio .Future [Any ]
282+ thread_send_queue : ThreadQueue [Any ]
283+ async_recv_queue : AsyncQueue [Any ]
288284
289285
290286@dataclass
0 commit comments