44
55from anyio import create_task_group
66from anyio .abc import TaskGroup
7- from jsonpatch import make_patch , apply_patch
87
98from .layout import (
109 LayoutEvent ,
@@ -122,14 +121,14 @@ async def run(
122121 async def _render_loop (self ) -> None :
123122 while True :
124123 update = await super ()._outgoing (self .layout , None )
125- self ._model_state = _apply_layout_update (self ._model_state , update )
124+ self ._model_state = update . apply_to (self ._model_state )
126125 # append updates to all other contexts
127126 for queue in self ._update_queues .values ():
128127 await queue .put (update )
129128
130129 async def _outgoing_loop (self , send : SendCoroutine , context : Any ) -> None :
131130 self ._update_queues [context ] = asyncio .Queue ()
132- await send (LayoutUpdate ( "" , make_patch ( {}, self ._model_state ). patch ))
131+ await send (LayoutUpdate . create_from ( {}, self ._model_state ))
133132 await super ()._outgoing_loop (send , context )
134133
135134 async def _outgoing (self , layout : Layout , context : str ) -> LayoutUpdate :
@@ -142,9 +141,3 @@ async def _join_event(self) -> AsyncIterator[asyncio.Event]:
142141 yield event
143142 finally :
144143 event .set ()
145-
146-
147- def _apply_layout_update (doc : Dict [str , Any ], update : LayoutUpdate ) -> Any :
148- return apply_patch (
149- doc , [{** c , "path" : update .path + c ["path" ]} for c in update .changes ]
150- )
0 commit comments