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:
Martin Bektchiev
2019-05-08 13:56:45 +03:00
parent f51bb119c2
commit c60f74d4eb
6 changed files with 87 additions and 7 deletions

View File

@ -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));
}
}