1  constructor(el, liveSocket, parentView){
 2    this.liveSocket = liveSocket
 3    this.parent = parentView
 4    this.newChildrenAdded = false
 5    this.gracefullyClosed = false
 6    this.el = el
 7    this.loader = this.el.nextElementSibling
 8    this.id = this.el.id
 9    this.view = this.el.getAttribute(PHX_VIEW)
10    this.channel = this.liveSocket.channel(`lv:${this.id}`, () => {
11      return {session: this.getSession()}
12    })
13    this.loaderTimer = setTimeout(() => this.showLoader(), LOADER_TIMEOUT)
14    this.bindChannel()
15  }

here's some code

posted Mar 26 at 18:21

this is stupid

2 Refactors


Preferred!

Shortest Code!

 1constructor(el, liveSocket, parentView){
 2    this.loader = this.el.nextElementSibling
 3    this.id = this.el.id
 4    this.view = this.el.getAttribute(PHX_VIEW)
 5    this.channel = this.liveSocket.channel(`lv:${this.id}`, () => {
 6      return {session: this.getSession()}
 7    })
 8    this.loaderTimer = setTimeout(() => this.showLoader(), LOADER_TIMEOUT)
 9    this.bindChannel()
10  }

our own thoughts

suggested Mar 26 at 18:21

this is not that bad


 1constructor(el, liveSocket, parentView){
 2    this.liveSocket = liveSocket
 3    this.parent = parentView
 4    this.newChildrenAdded = false
 5    this.gracefullyClosed = false
 6    this.el = el
 7    this.loader = this.el.nextElementSibling
 8    this.id = this.el.id
 9    this.view = this.el.getAttribute(PHX_VIEW)
10    this.channel = this.liveSocket.channel(`lv:${this.id}`, () => {
11      return {session: this.getSession()}
12    })
13    this.loaderTimer = setTimeout(() => this.showLoader(), LOADER_TIMEOUT)
14    
15  }

some ideas

suggested Apr 17 at 22:19