Skip to content

Commit 08f64e3

Browse files
committed
Added safety check to load & start in app.
1 parent d0c319a commit 08f64e3

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 - 2024 Toreda
3+
Copyright (c) 2019 - 2025 Toreda
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@
99
 
1010

1111
# `@toreda/typescript-cli-starter`
12-
## Command line (CLI) starter app project
12+
## Command line (CLI) app template
1313
Command Line Interface (CLI) app example using TypeScript. Produces a self-contained bundle file which can be installed and execute via command line.
1414

1515
 
1616

17-
# Starter Features
18-
19-
## Features
17+
# Template Features
2018
- Unit tests with Jest.
2119
- TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor.
2220
- TypeScript understands JavaScript and uses type inference to give you great tooling without additional code.
2321

2422
 
2523

26-
2724
## [Speedy Web Compiler (SWC)](https://swc.rs/)
2825
*WC is an extensible Rust-based platform for the next generation of fast developer tools. It's used by tools like Next.js, Parcel, and Deno, as well as companies like Vercel, ByteDance, Tencent, Shopify, and more.*
2926

@@ -429,6 +426,21 @@ TypeScript package support with `tsconfig.json`.
429426

430427
 
431428

429+
# Client Lifecycle
430+
Lifecycle methods are like checkpoints that execute logic at each step in the client's lifecycle flow.
431+
432+
## `Init Phase`
433+
Init
434+
435+
The async init methods are called in the following order:
436+
### 1. `clientWillInit`
437+
### 2. `clientOnInit`
438+
### 3. `clientDidInit`
439+
440+
## `Load Phase`
441+
442+
443+
432444
# Legal
433445

434446
## License

src/app.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@ export class App implements ClientDelegate {
4949

5050
this.loaded(true);
5151
return this;
52-
5352
}
5453

54+
/**
55+
* Start the app. Ignores all start calls after app is running.
56+
*/
5557
public async start(): Promise<App> {
5658
// Ignore dupe calls after app start. Lifecycle phases maintain their own flags
5759
// to prevent dupe calls, but other logic here isn't protected without the check.
5860
if (this.running()) {
5961
return this;
6062
}
6163

62-
this.log.info(`CLI App starting..`);
64+
this.log.info(`Starting app..`);
6365
await this.load();
6466
await clientPhase('clientWillStart', this);
6567
await clientPhase('clientOnStart', this);
@@ -68,6 +70,8 @@ export class App implements ClientDelegate {
6870
await clientPhase('clientWillBecomeReady', this);
6971
await clientPhase('clientOnReady', this);
7072
await clientPhase('clientDidBecomeReady', this);
73+
this.log.info(`App started.`);
74+
this.running(true);
7175

7276
return this;
7377
}

0 commit comments

Comments
 (0)