diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-15 15:24:33 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-15 15:24:33 +0000 |
commit | ad235b2210f57976c0a95cb35aee531276391c0b (patch) | |
tree | 058e917571dc8bdee0db999d537de3c70c394d13 | |
parent | 7d451a63b6136d7532f17407d623ff3956c2990b (diff) | |
download | gitlab-ce-update-singleton-pattern-docs.tar.gz |
Remove singleton guidelinesupdate-singleton-pattern-docs
-rw-r--r-- | doc/development/fe_guide/design_patterns.md | 46 |
1 files changed, 0 insertions, 46 deletions
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. |