Skip to content

Commit 44a9c15

Browse files
authored
feat(vscode): define singleton DartFrogDeamon (#917)
1 parent 88a65d9 commit 44a9c15

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The Dart Frog daemon is a long-running process that is responsible for
3+
* managing a single or multiple Dart Frog projects simultaneously.
4+
*
5+
* @see {@link https://dartfrog.vgv.dev/docs/advanced/daemon Dart Frog deamon documentation }
6+
*/
7+
export class DartFrogDaemon {
8+
private static _instance: DartFrogDaemon;
9+
10+
/**
11+
* A singleton instance of the Dart Frog daemon.
12+
*
13+
* A Dart Frog daemon can manage multiple Dart Frog projects simultaneously.
14+
*/
15+
public static get instance() {
16+
return this._instance || (this._instance = new this());
17+
}
18+
}

extensions/vscode/src/daemon/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./dart-frog-daemon";
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import assert = require("assert");
2+
import { DartFrogDaemon } from "../../../daemon";
3+
4+
suite("DartFrogDaemon", () => {
5+
test("instance retrieves a singleton", () => {
6+
const dartFrogDaemon = DartFrogDaemon.instance;
7+
const dartFrogDaemon2 = DartFrogDaemon.instance;
8+
9+
assert.equal(dartFrogDaemon, dartFrogDaemon2);
10+
});
11+
});

0 commit comments

Comments
 (0)