mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(devtools-ios): Ensure UI modifications run on main thread
Modifications to the UI can only be made from the main thread. Since {N} 5.3.0 all debugger protocol messages are processed by the worker thread that receives them in iOS. refs #7219, https://github.com/NativeScript/ios-runtime/pull/1101
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import * as types from "./types";
|
||||
import { executeOnMainThread } from "./utils"
|
||||
|
||||
export const RESOURCE_PREFIX = "res://";
|
||||
export const FILE_PREFIX = "file:///";
|
||||
@ -154,3 +155,10 @@ export function hasDuplicates(arr: Array<any>): boolean {
|
||||
export function eliminateDuplicates(arr: Array<any>): Array<any> {
|
||||
return Array.from(new Set(arr));
|
||||
}
|
||||
|
||||
export function mainThreadify(func: Function): (...args: any[]) => void {
|
||||
return function () {
|
||||
const argsToPass = arguments;
|
||||
executeOnMainThread(() => func.apply(this, argsToPass));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user