Last Updated: February 25, 2016
·
1.3K
· robinduckett

Make a singleton in CoffeeScript

class SingletonClass
    constructor: () ->
        @list = []
    getList: ->
        @list


INSTANCE = undefined

Singleton =
    instance: ->
        if INSTANCE is undefined
            INSTANCE = new SingletonClass()

        INSTANCE