Skip to content

Singleton pattern #1

@simplast

Description

@simplast

A Singleton only allows for a single instantiation, but many instances of the same object. The Singleton restricts clients from creating multiple objects, after the first object created, it will return instances of itself.

  const getSingle = function(fn){
    let instance;
    return function() {
      return instance || (instance = fn.apply(this, arguments))
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions