Adds bootstrap example
This commit is contained in:
parent
4499bf05a7
commit
4cc0ab1eef
@ -52,6 +52,7 @@ button.addEventListener("clicked", () => {
|
||||
if (rootView.layout) {
|
||||
(rootView.layout as FlexLayout).removeWidget(dial);
|
||||
}
|
||||
label.setInlineStyle("color:blue;");
|
||||
});
|
||||
|
||||
const nodeguiLogo = new QIcon(
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// bootstrap
|
||||
import "./lib/core/bootstrap";
|
||||
// Enums:
|
||||
export * from "./lib/QtEnums";
|
||||
// Gui:
|
||||
|
||||
@ -19,7 +19,7 @@ export const prepareInlineStyleSheet = async (
|
||||
rawStyle: string
|
||||
) => {
|
||||
const inlineStyle = await StyleSheet.create(rawStyle);
|
||||
// Make sure to not calculate ObjectName is the same pass of event loop as other props (incase of react) since the order will matter in that case
|
||||
// Make sure to not calculate ObjectName in the same pass of event loop as other props (incase of react) since the order will matter in that case
|
||||
// So doing it in multiple passes of event loop allows objectName to be set before using it. The above await solves it.
|
||||
let cssId = widget.objectName();
|
||||
if (!cssId) {
|
||||
@ -38,7 +38,5 @@ export const applyStyleSheet = async (
|
||||
styleSheet: string
|
||||
) => {
|
||||
widget.native.setStyleSheet(styleSheet);
|
||||
setTimeout(() => {
|
||||
widget.layout ? widget.layout.update() : widget.update();
|
||||
}, 20);
|
||||
widget.layout ? widget.layout.update() : widget.update();
|
||||
};
|
||||
|
||||
26
src/lib/core/bootstrap.ts
Normal file
26
src/lib/core/bootstrap.ts
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
From: https://github.com/yue/yode/blob/master/src/bootstrap.js
|
||||
setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
||||
run the callbacks, however since we only run uv loop on requests, the
|
||||
callbacks wouldn't be called until something else activated the uv loop,
|
||||
which would delay the callbacks for arbitrary long time. So we should
|
||||
initiatively activate the uv loop once setImmediate and process.nextTick is
|
||||
called.
|
||||
This is required inorder to make the timers work nicely due to merger of event loops
|
||||
*/
|
||||
function wrapWithActivateUvLoop(func: any) {
|
||||
return function() {
|
||||
(process as any).activateUvLoop();
|
||||
//@ts-ignore
|
||||
return func.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
const main = () => {
|
||||
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
|
||||
global.setImmediate = wrapWithActivateUvLoop(global.setImmediate);
|
||||
global.setTimeout = wrapWithActivateUvLoop(global.setTimeout);
|
||||
global.setInterval = wrapWithActivateUvLoop(global.setInterval);
|
||||
};
|
||||
|
||||
main();
|
||||
Loading…
Reference in New Issue
Block a user