Comparing version 0.10.18 to 0.10.19
@@ -347,3 +347,5 @@ /* | ||
function createFactory(constructor) { | ||
return (constructor.prototype.singleton) ? | ||
// DEPRECATED: constructor.prototype.singleton is deprecated. "singleton" | ||
// static property on the constructor is preferred | ||
return (constructor.singleton || constructor.prototype.singleton) ? | ||
new SingletonComponentFactory(constructor) : | ||
@@ -401,6 +403,12 @@ new ComponentFactory(constructor); | ||
function noop() {} | ||
function SingletonComponentFactory(constructor) { | ||
this.constructor = constructor; | ||
this.component = null; | ||
// Disable component from being destroyed, since it is intended to | ||
// be used multiple times | ||
constructor.prototype.destroy = noop; | ||
} | ||
SingletonComponentFactory.prototype.isSingleton = true; | ||
SingletonComponentFactory.prototype.init = function(context) { | ||
@@ -410,4 +418,4 @@ if (!this.component) this.component = new this.constructor(); | ||
}; | ||
// Don't call the create method for singleton components | ||
SingletonComponentFactory.prototype.create = function() {}; | ||
// Don't call the init or create methods for singleton components | ||
SingletonComponentFactory.prototype.create = noop; | ||
@@ -431,2 +439,12 @@ function isBasePrototype(object) { | ||
var rootPrototype = getRootPrototype(constructor.prototype); | ||
// This guard is a workaroud to a bug that has occurred in Chakra when | ||
// app.component() is invoked twice on the same constructor. In that case, | ||
// the `instanceof Component` check in extendComponent incorrectly returns | ||
// false after the prototype has already been set to `Component.prototype`. | ||
// Then, this code proceeds to set the prototype of Component.prototype | ||
// to itself, which throws a "Cyclic __proto__ value" error. | ||
// https://github.com/Microsoft/ChakraCore/issues/5915 | ||
if (rootPrototype === Component.prototype) return; | ||
// Establish inheritance with the pattern that Node's util.inherits() uses | ||
@@ -433,0 +451,0 @@ // if Object.setPrototypeOf() is available (all modern browsers & IE11). |
@@ -273,5 +273,3 @@ var derbyTemplates = require('derby-templates'); | ||
var component = node.$component; | ||
if (component && !component.singleton) { | ||
component.destroy(); | ||
} | ||
if (component) component.destroy(); | ||
var destroyListeners = node.$destroyListeners; | ||
@@ -278,0 +276,0 @@ if (destroyListeners) { |
{ | ||
"name": "derby", | ||
"description": "MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers.", | ||
"version": "0.10.18", | ||
"version": "0.10.19", | ||
"homepage": "http://derbyjs.com/", | ||
@@ -6,0 +6,0 @@ "repository": { |
173264
4433