mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
Add 1.0 preview mode bridge Model class
This commit is contained in:
parent
8ceb2e2028
commit
488e40e635
@ -8,7 +8,6 @@ shell = require 'shell'
|
|||||||
_ = require 'underscore-plus'
|
_ = require 'underscore-plus'
|
||||||
{deprecate, includeDeprecations} = require 'grim'
|
{deprecate, includeDeprecations} = require 'grim'
|
||||||
{CompositeDisposable, Emitter} = require 'event-kit'
|
{CompositeDisposable, Emitter} = require 'event-kit'
|
||||||
{Model} = require 'theorist'
|
|
||||||
fs = require 'fs-plus'
|
fs = require 'fs-plus'
|
||||||
{convertStackTrace, convertLine} = require 'coffeestack'
|
{convertStackTrace, convertLine} = require 'coffeestack'
|
||||||
|
|
||||||
@ -16,13 +15,16 @@ fs = require 'fs-plus'
|
|||||||
WindowEventHandler = require './window-event-handler'
|
WindowEventHandler = require './window-event-handler'
|
||||||
StylesElement = require './styles-element'
|
StylesElement = require './styles-element'
|
||||||
|
|
||||||
SuperClass = if includeDeprecations then Model else Object
|
if includeDeprecations
|
||||||
|
{Model} = require 'theorist'
|
||||||
|
else
|
||||||
|
Model = require './model'
|
||||||
|
|
||||||
# Essential: Atom global for dealing with packages, themes, menus, and the window.
|
# Essential: Atom global for dealing with packages, themes, menus, and the window.
|
||||||
#
|
#
|
||||||
# An instance of this class is always available as the `atom` global.
|
# An instance of this class is always available as the `atom` global.
|
||||||
module.exports =
|
module.exports =
|
||||||
class Atom extends SuperClass
|
class Atom extends Model
|
||||||
@version: 1 # Increment this when the serialization format changes
|
@version: 1 # Increment this when the serialization format changes
|
||||||
|
|
||||||
# Load or create the Atom environment in the given mode.
|
# Load or create the Atom environment in the given mode.
|
||||||
|
27
src/model.coffee
Normal file
27
src/model.coffee
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
PropertyAccessors = require 'property-accessors'
|
||||||
|
|
||||||
|
nextInstanceId = 1
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
class Model
|
||||||
|
PropertyAccessors.includeInto(this)
|
||||||
|
|
||||||
|
@resetNextInstanceId: -> nextInstanceId = 1
|
||||||
|
|
||||||
|
constructor: (params) ->
|
||||||
|
@assignId(params?.id)
|
||||||
|
|
||||||
|
assignId: (id) ->
|
||||||
|
@id ?= id ? nextInstanceId++
|
||||||
|
|
||||||
|
@::advisedAccessor 'id',
|
||||||
|
set: (id) -> nextInstanceId = id + 1 if id >= nextInstanceId
|
||||||
|
|
||||||
|
destroy: ->
|
||||||
|
return unless @isAlive()
|
||||||
|
@alive = false
|
||||||
|
@destroyed?()
|
||||||
|
|
||||||
|
isAlive: -> @alive
|
||||||
|
|
||||||
|
isDestroyed: -> not @isAlive()
|
Loading…
Reference in New Issue
Block a user