-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): define singleton DartFrogDeamon (#917)
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* The Dart Frog daemon is a long-running process that is responsible for | ||
* managing a single or multiple Dart Frog projects simultaneously. | ||
* | ||
* @see {@link https://dartfrog.vgv.dev/docs/advanced/daemon Dart Frog deamon documentation } | ||
*/ | ||
export class DartFrogDaemon { | ||
private static _instance: DartFrogDaemon; | ||
|
||
/** | ||
* A singleton instance of the Dart Frog daemon. | ||
* | ||
* A Dart Frog daemon can manage multiple Dart Frog projects simultaneously. | ||
*/ | ||
public static get instance() { | ||
return this._instance || (this._instance = new this()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./dart-frog-daemon"; |
11 changes: 11 additions & 0 deletions
11
extensions/vscode/src/test/suite/daemon/dart-frog-daemon.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import assert = require("assert"); | ||
import { DartFrogDaemon } from "../../../daemon"; | ||
|
||
suite("DartFrogDaemon", () => { | ||
test("instance retrieves a singleton", () => { | ||
const dartFrogDaemon = DartFrogDaemon.instance; | ||
const dartFrogDaemon2 = DartFrogDaemon.instance; | ||
|
||
assert.equal(dartFrogDaemon, dartFrogDaemon2); | ||
}); | ||
}); |