mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 05:44:52 +00:00

As it happens, the run() call is the last call in the app, so it also works without await. But the moment somebody adds code after run(), they'd be surprised that it gets called "before" run. So await for good measure.
23 lines
620 B
JavaScript
23 lines
620 B
JavaScript
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// ANCHOR: main
|
|
// main.js
|
|
import * as slint from "slint-ui";
|
|
let ui = slint.loadFile("./memory.slint");
|
|
let mainWindow = new ui.MainWindow();
|
|
|
|
let initial_tiles = mainWindow.memory_tiles;
|
|
let tiles = initial_tiles.concat(initial_tiles.map((tile) => Object.assign({}, tile)));
|
|
|
|
for (let i = tiles.length - 1; i > 0; i--) {
|
|
const j = Math.floor(Math.random() * i);
|
|
[tiles[i], tiles[j]] = [tiles[j], tiles[i]];
|
|
}
|
|
|
|
let model = new slint.ArrayModel(tiles);
|
|
mainWindow.memory_tiles = model;
|
|
|
|
await mainWindow.run();
|
|
|
|
// ANCHOR_END: main
|