Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 310 Bytes

variable.litcoffee

File metadata and controls

16 lines (12 loc) · 310 Bytes
Variable = (initialValue) ->

  value = initialValue
  dep = new Deps.Dependency()

  fn = ->
    dep.depend()
    return value

  fn.set = (newValue) ->
    unless EJSON.equals(newValue, value)
      value = newValue
      dep.changed()
    return

  return fn