From ad235b2210f57976c0a95cb35aee531276391c0b Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Mon, 15 May 2017 15:24:33 +0000 Subject: Remove singleton guidelines --- doc/development/fe_guide/design_patterns.md | 46 ----------------------------- 1 file changed, 46 deletions(-) (limited to 'doc/development/fe_guide') diff --git a/doc/development/fe_guide/design_patterns.md b/doc/development/fe_guide/design_patterns.md index ffca801fd03..a2f1a517d79 100644 --- a/doc/development/fe_guide/design_patterns.md +++ b/doc/development/fe_guide/design_patterns.md @@ -1,51 +1,5 @@ # Design Patterns -## Singletons - -As with everything at GitLab, the simplest approach should be taken. -Below we have defined a few patterns to achieve singleton-like behaviour. -Pick the simplest one that fits your usecase. - -```javascript -const MyThing = { - prop: 'hello', - init: () => {} -}; - -export default MyThing; -``` - -```javascript -class MyThing { - constructor() { - this.prop = 'hello'; - } - init() {} -} - -export default new MyThing(); -``` - -```javascript - -export default class MyThing { - constructor() { - if (!this.prototype.singleton) { - this.init(); - this.prototype.singleton = this; - } - return this.prototype.singleton; - } - - init() { - this.prop = 'hello'; - } - - method1() {} -} - -``` - ## Manipulating the DOM in a JS Class When writing a class that needs to manipulate the DOM guarantee a container option is provided. -- cgit v1.2.1