@@ -95,9 +95,10 @@ async def update(msg: Msg, model: Model[TSource]) -> Model[TSource]:
95
95
96
96
return model .replace (is_stopped = True )
97
97
98
- # default case
99
- for key , dispose in model .subscriptions :
100
- await dispose .dispose_async ()
98
+ while m .default ():
99
+ for key , dispose in model .subscriptions :
100
+ await dispose .dispose_async ()
101
+
101
102
return initial_model .replace (is_stopped = True )
102
103
103
104
async def message_loop (model : Model [TSource ]) -> None :
@@ -181,12 +182,14 @@ async def get_value(n: Notification[TSource]) -> Option[TSource]:
181
182
await n .accept_observer (safe_obv )
182
183
return Nothing
183
184
184
- if isinstance (cn , SourceMsg ):
185
- cn = cast (SourceMsg [TSource ], cn )
186
- source_value = await get_value (cn .value )
187
- else :
188
- cn = cast (OtherMsg [TOther ], cn )
189
- other_value = await get_value (cn .value )
185
+ m = match (cn )
186
+ for value in SourceMsg .case (m ):
187
+ source_value = await get_value (value )
188
+ break
189
+
190
+ for value in OtherMsg .case (m ):
191
+ other_value = await get_value (value )
192
+ break
190
193
191
194
def binder (s : TSource ) -> Option [Tuple [TSource , TOther ]]:
192
195
def mapper (o : TOther ) -> Tuple [TSource , TOther ]:
0 commit comments