Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vscode): define singleton DartFrogDeamon #917

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";
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);
});
});