wwmq6a
Last Updated: February 25, 2016
·
1.167K
· robinduckett

Make a singleton in CoffeeScript

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


INSTANCE = undefined

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

        INSTANCE