mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
24 lines
407 B
CoffeeScript
24 lines
407 B
CoffeeScript
nextInstanceId = 1
|
|
|
|
module.exports =
|
|
class Model
|
|
@resetNextInstanceId: -> nextInstanceId = 1
|
|
|
|
alive: true
|
|
|
|
constructor: (params) ->
|
|
@assignId(params?.id)
|
|
|
|
assignId: (id) ->
|
|
@id ?= id ? nextInstanceId++
|
|
nextInstanceId = id + 1 if id >= nextInstanceId
|
|
|
|
destroy: ->
|
|
return unless @isAlive()
|
|
@alive = false
|
|
@destroyed?()
|
|
|
|
isAlive: -> @alive
|
|
|
|
isDestroyed: -> not @isAlive()
|