Skip to content

Commit

Permalink
Added Singleton pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 12, 2017
1 parent a844417 commit 2ba4d2c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/manager/VirtualFSManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { VirtualResource } from '../resource/VirtualResource';
import { IResource, ResourceType } from '../resource/Resource';
import { FSManager } from './FSManager';
export declare class VirtualFSManager implements FSManager {
private static _instance;
static instance(): VirtualFSManager;
serialize(resource: any): object;
unserialize(serializedResource: {
name;
Expand Down
5 changes: 5 additions & 0 deletions lib/manager/VirtualFSManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ var VirtualResource_1 = require("../resource/VirtualResource");
var VirtualFSManager = (function () {
function VirtualFSManager() {
}
VirtualFSManager.instance = function () {
if (!this._instance)
this._instance = new VirtualFSManager();
return this._instance;
};
VirtualFSManager.prototype.serialize = function (resource) {
var obj;
obj.name = resource.name;
Expand Down
8 changes: 8 additions & 0 deletions src/manager/VirtualFSManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { FSManager } from './FSManager'

export class VirtualFSManager implements FSManager
{
private static _instance : VirtualFSManager;
static instance()
{
if(!this._instance)
this._instance = new VirtualFSManager();
return this._instance;
}

serialize(resource : any) : object
{
let obj : {
Expand Down

0 comments on commit 2ba4d2c

Please sign in to comment.