ThemeManager emits a reload event when reloaded

This commit is contained in:
Ben Ogle
2013-08-13 17:01:45 -07:00
parent 6cd003f68e
commit b89e58e551
2 changed files with 8 additions and 0 deletions

View File

@@ -7,10 +7,13 @@ describe "ThemeManager", ->
describe "when the core.themes config value changes", ->
it "add/removes stylesheets to reflect the new config value", ->
themeManager = new ThemeManager()
themeManager.on 'reload', reloadHandler = jasmine.createSpy()
spyOn(themeManager, 'getUserStylesheetPath').andCallFake -> null
themeManager.load()
config.set('core.themes', [])
expect($('style.userTheme').length).toBe 0
expect(reloadHandler).toHaveBeenCalled()
config.set('core.themes', ['atom-dark-syntax'])
expect($('style.userTheme').length).toBe 1

View File

@@ -1,4 +1,5 @@
path = require 'path'
EventEmitter = require 'event-emitter'
_ = require 'underscore'
@@ -7,6 +8,8 @@ Theme = require 'theme'
module.exports =
class ThemeManager
_.extend @prototype, EventEmitter
constructor: ->
@loadedThemes = []
@@ -27,6 +30,8 @@ class ThemeManager
@loadTheme(themeName) for themeName in themeNames
@loadUserStylesheet()
@trigger('reload')
loadTheme: (name) ->
try
@loadedThemes.push(new Theme(name))