@@ -144,17 +144,21 @@ final class App {
144
144
}
145
145
146
146
private func setupEventHandlers( ) {
147
- indexButton. onclick = . object( JSClosure { [ weak self] _ in
148
- guard let self else { return . undefined }
149
- self . performIndex ( )
150
- return . undefined
151
- } )
152
-
153
- searchButton. onclick = . object( JSClosure { [ weak self] _ in
154
- guard let self else { return . undefined }
155
- self . performSearch ( )
156
- return . undefined
157
- } )
147
+ indexButton. onclick = . object(
148
+ JSClosure { [ weak self] _ in
149
+ guard let self else { return . undefined }
150
+ self . performIndex ( )
151
+ return . undefined
152
+ }
153
+ )
154
+
155
+ searchButton. onclick = . object(
156
+ JSClosure { [ weak self] _ in
157
+ guard let self else { return . undefined }
158
+ self . performSearch ( )
159
+ return . undefined
160
+ }
161
+ )
158
162
}
159
163
160
164
private func performIndex( ) {
@@ -221,7 +225,8 @@ final class App {
221
225
" padding: 10px; margin: 5px 0; background: #f5f5f5; border-left: 3px solid blue; "
222
226
)
223
227
resultItem. innerHTML = . string(
224
- " <strong>Result \( index + 1 ) :</strong> \( result. context) " )
228
+ " <strong>Result \( index + 1 ) :</strong> \( result. context) "
229
+ )
225
230
_ = resultsElement. appendChild ( resultItem)
226
231
}
227
232
}
@@ -245,18 +250,18 @@ final class App {
245
250
}
246
251
247
252
#if canImport(wasi_pthread)
248
- import wasi_pthread
249
- import WASILibc
250
-
251
- /// Trick to avoid blocking the main thread. pthread_mutex_lock function is used by
252
- /// the Swift concurrency runtime.
253
- @_cdecl ( " pthread_mutex_lock " )
254
- func pthread_mutex_lock( _ mutex: UnsafeMutablePointer < pthread_mutex_t > ) -> Int32 {
255
- // DO NOT BLOCK MAIN THREAD
256
- var ret : Int32
257
- repeat {
258
- ret = pthread_mutex_trylock ( mutex)
259
- } while ret == EBUSY
260
- return ret
261
- }
253
+ import wasi_pthread
254
+ import WASILibc
255
+
256
+ /// Trick to avoid blocking the main thread. pthread_mutex_lock function is used by
257
+ /// the Swift concurrency runtime.
258
+ @_cdecl ( " pthread_mutex_lock " )
259
+ func pthread_mutex_lock( _ mutex: UnsafeMutablePointer < pthread_mutex_t > ) -> Int32 {
260
+ // DO NOT BLOCK MAIN THREAD
261
+ var ret : Int32
262
+ repeat {
263
+ ret = pthread_mutex_trylock ( mutex)
264
+ } while ret == EBUSY
265
+ return ret
266
+ }
262
267
#endif
0 commit comments