4
4
5
5
from anyio import create_task_group
6
6
from anyio .abc import TaskGroup
7
- from jsonpatch import make_patch , apply_patch
8
7
9
8
from .layout import (
10
9
LayoutEvent ,
@@ -122,14 +121,14 @@ async def run(
122
121
async def _render_loop (self ) -> None :
123
122
while True :
124
123
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 )
126
125
# append updates to all other contexts
127
126
for queue in self ._update_queues .values ():
128
127
await queue .put (update )
129
128
130
129
async def _outgoing_loop (self , send : SendCoroutine , context : Any ) -> None :
131
130
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 ))
133
132
await super ()._outgoing_loop (send , context )
134
133
135
134
async def _outgoing (self , layout : Layout , context : str ) -> LayoutUpdate :
@@ -142,9 +141,3 @@ async def _join_event(self) -> AsyncIterator[asyncio.Event]:
142
141
yield event
143
142
finally :
144
143
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