Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Enable components to emit ready after they've configured themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Jun 3, 2012
1 parent bcc8ea4 commit 6aa26f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/Extension.coffee
Expand Up @@ -9,8 +9,9 @@ in NodeXT:
###
{_} = require 'underscore'
path = require 'path'
events = require 'events'

class Extension
class Extension extends events.EventEmitter
###
## NodeXT extension baseclass
Expand Down Expand Up @@ -67,6 +68,8 @@ class Extension
Register routes to Express server under given prefix
###

isReady: -> true

exports.Extension = Extension

loaded = {}
Expand Down
6 changes: 5 additions & 1 deletion lib/server.coffee
Expand Up @@ -63,6 +63,10 @@ exports.createApplication = (config) ->
server.set 'views', config.server.view.options.root

for name, extension of extensions
extension.registerRoutes server
if extension.isReady()
extension.registerRoutes server
continue
extension.once 'ready', ->
extension.registerRoutes server

server
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"description": "Plugin-driven Node.js applications",
"keywords": ["server", "express", "extension", "framework"],
"author": "Henri Bergius",
"version": "0.1.2",
"version": "0.1.3",
"licenses": [{
"type": "MIT",
"url": "https://github.com/bergie/nodext/raw/master/LICENSE"
Expand Down

0 comments on commit 6aa26f6

Please sign in to comment.