Skip to content

Commit

Permalink
feat(vscode): define singleton DartFrogDeamon (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Aug 14, 2023
1 parent 88a65d9 commit 44a9c15
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions extensions/vscode/src/daemon/dart-frog-daemon.ts
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());
}
}
1 change: 1 addition & 0 deletions extensions/vscode/src/daemon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dart-frog-daemon";
11 changes: 11 additions & 0 deletions extensions/vscode/src/test/suite/daemon/dart-frog-daemon.test.ts
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);
});
});

0 comments on commit 44a9c15

Please sign in to comment.