- Removes deprecated
grigio:[email protected]
meteor dependency. It was causing errors related to long or failed builds (like:Cannot enlarge memory arrays
)
- Fixes the BDD test helper on
Space.Module
andSpace.Application
to actually accept a second param that can be a existing app instance.
- Fixes superClass method for classes that are not directly extending Space.Object
-
Improves the way mixins are applied to classes and ensures that:
- Sub classes always inherit all mixins applied to parent classes, even when this happens "later on"
- All sub classes inherit the static mixin properties, even after extending the base class
-
Adds the following helpers are added to
Space.Object
for convenience:- static
MyClass.hasSuperClass()
MyClass.superClass([key])
- either returns the super class constructor or static property/methodMyClass.subClasses()
- returns flat array of all sub classes
- prototype
myInstance.hasSuperClass()
myInstance.superClass([key])
- same as static version but returns prototype props/methods
- static
- Adds
hasMixin()
instance method to Space.Object to check if the class has applied or inherited a specific mixin
Space.Struct
were previously not calling their super constructor which caused a bug with the newonConstruction
hooks
- Improves
Space.Object.extend()
implementations - Fixes bug in
Space.Error
- Adds tests for mixin callbacks
This is a big major release with many new features and improvements:
- Adds extensible
Space.Error
class that has the same api asSpace.Object
but can be used for better custom error classes.
// When throwing this: "MyError: The default message for this error"
let MyError = Space.Error.extend('MyError', {
message: 'The default message for this error'
});
// When throwing this: "MyParamError: Custom message with <param>"
let MyError = Space.Error.extend('MyParamError', {
Constructor: (param) {
Space.Error.call(this, `Custom message with ${param}`);
}
});
- Improves mixins for
Space.Object
by makingonDependenciesReady
hooks available. All mixins can now define their ownonDependenciesReady
methods which all get called by the host class correctly. This way mixins can do setup work on host classes.
My.CustomMixin = {
onDependenciesReady() { // Do some setup work }
};
My.CustomClass.mixin(My.CustomMixin);
// Of course normally you dont have to call `onDependenciesReady` yourself
new My.CustomClass().onDependenciesReady() // Mixin hook is called!
- You can now add mixins to any subclass of
Space.Object
like this:
Space.Object.extend('CustomClass', { mixin: [FirstMixin, SecondMixin] });
-
Mixin methods now override methods on the host class!
-
Many bugfixes and improvements related to
Space.Module
lifecycle hooks. Previous hooks likeonStart
andonConfigure
have been replaced with a complete lifecycle split into three main phases:initialize
,start
,reset
. Each withon
,before
andafter
hooks likeonInitialize
/afterStart
etc. -
Refactored all core api properties like
Dependencies
,RequiredModules
,Singletons
etc. to lowercase pendants: e.gdependencies
,requiredModules
-
Added
Space.Logger
, an extensible logger based on winston available in your application asdependencies: { log: 'log' }
-
You can now do static setup work on classes like this:
Space.Object.extend('CustomClass', {
onExtending() {
// <this> is the class itself here!
}
});
-
Adds static
Space.Object.isSubclassOf
method that is available for all sub classes automatically. So you can askMyFirstClass.isSubclassOf(OtherClass)
-
Improved error handling and messages of
Space.Injector
(DI System) -
Space.Struct
can now be serializedtoData
andSpace.Struct.fromData
which has some benefits over EJSON: all fields are plain and accessible for queries! -
New recommended way to define classes with full class path for improved debugging and automatic type registration (EJSON / toData):
// Instead of:
Space.Object.extend(My.namespace, 'MyCustomClass');
// Do this now:
Space.Object.extend('My.namespace.MyCustomClass');
-
Added proper MIT license
-
Added BDD test helper
Space.Module.registerBddApi
Thanks to all the new people on the team who made this awesome release possible:
👏
- Bug fixes relating to package configuration
Module/Application state and lifecycle improvements
- Formalizes state to better manage module lifecycle
- States include: Constructed -> Initialized -> Stopped -> Running
- Accessor method
app.is(expectedState) // eg 'running'
- Calling .reset() on a running Application or Module now calls .stop() on it first, then start() again after it's been reset.
Configuration API Support
Space.getenv
helper wraps getenv to provide support for ENV typecasting, particularly for merging with runtime config
Other Changes
- Default Meteor mappings have been moved down to Module from Application
MongoInternals
is now mapped on the server
Bugfixes
- Minor injector fixes, with better error handling.
- Fixes bug with recently updated injector code
- Fixed bug with module lifecycle hooks
- Improved
Space.Object
mixin api to make it possible to mixin static class properties via the specialStatic
property and to do static setup when the mixin is applied by providing aonMixinApplied
method in the mixin definition. Both properties are not added to the prototype of course. TheonMixinApplied
method is called with the host class asthis
context.
Several breaking changes and API improvements have been made:
ReactiveVar
is now mapped statically instead ofinstancesOf
, so you can use it like the "normal"- The module/app lifecycle has been harmonized into a simple system:
There are 4 lifecycle phases:
initialize
,start
,reset
andstop
. For each phase there arebefore
,on
, andafter
hooks that are called in the logical order -> deepest nested module first. Theinitialize
method is the only one that should not be called from outside but is automatically called when constructing a module/app. - The configuration API slightly changed again: The
configure
method is only defined onSpace.Application
and allows to override the default config of the app / modules. - The previous
configure
hooks does not exist anymore. You should useonInitialize
instead.
- Thanks @sanjo for a patch that fixes dependency injection if two components depend on each other.
Several improvements and bug fixes have been made:
- Keep the required min version of Meteor down to 1.0
- Added
afterApplicationStart
hook for modules and apps that is called after everything has been configured and started. - Improved configuration api to allow overriding of arbitrarily nested configuration values. This is super awesome for overriding configs of modules.
- Added
Space.Object#type
api for adding debug info about class types. - Added
stop
hook for modules and apps that is similar toreset
but should be used for really drastic cleanup (like stopping observers etc.)
Fixes some bugs with the new Meteor dependency tracker and the default dependency injections in Space applications.
Introduces better way to configure modules and applications. Now you can
define a default Configuration
property on the prototype and override
specific values of it when creating the application instance like this:
new TestApp({
Configuration: {
propertyToOverride: 'customValue',
}
});
All configurations are merged into a single Configuration
object available
via the application injector like this: injector.get('Configuration')
.
Introduces dynamic overriding of injected dependencies in the running system.
Now you can call injector.override('Test').to('newValue')
and all objects
that had the previous value of Test
injected will be updated with the new
value dynamically. This makes it possible to swap out complete sub-systems
while the application is running. Of course it also comes with the potential
of memory leaks, because now the injection mappings have to hold references
to each and every object that dependencies are injected to. That's where the
new Space.Injector::release
API comes to play. If you have an object that
should be garbage collected but has dependencies injected you need to release
it from the Injector to let the mappings remove the references. In reality you
rarely have to manage this yourself because other packages like space:ui
will
handle this transparently in the background.
Only updated the Github repository links after moving it to the new https://github.com/meteor-space organization.
- Adds
Space.namespace('MyNamespace')
which simplifies working with Meteor package scopes. Up until now Space could not resolve exported variables from packages in your app because Meteor is hiding them from thespace:base
package.
- Improves
Space.Object.extend
capabilities to work smoothly with Javascript and provide multiple ways to extend core classes. - Improves general debugging experience by throwing errors when values can
not be resolved with
Space.resolvePath
Space.resolvePath
now also takes into account published space modules, which solves the problem of Meteor package scoping.- adds
Space.Module.define
andSpace.Application.define
which makes it easier to flesh out modules and apps in Javascript (without having to callpublish
)
Introduces lazy auto-mapping of singletons and static values if they are
requested by other parts via the Dependencies
property. For the first request
it looks up the dependency on the global context and maps functions as singletons
and other values as static. Be aware that some part of the system has to require
your singleton before it ever exists. In some cases this is not what you want
(e.g event handling)
@Sanjo fixed an issue with weak-dependencies injection in Space.Application
.
- Unified the API for starting
Space.Module
andSpace.Application
. This means you have to callyourApp.start()
instead ofyourApp.run()
now. - Renamed the
run
hook for modules and applications tostartup
, so instead of definingrun: function() { … }
you needstartup: function() { … }
inside your modules and apps now.
Make it possible to declare Singletons: []
on any module with paths to classes
that should be mapped and created as singletons automatically.
Fixes some package dependency issues
Adds basic mixin capabilities to Space.Object that allows to extend the prototype of a given class without direct inheritance
Fixes bug with running dependent modules in correct order.
Throw error when trying to map undefined
or null
value.
Adds helpers specs and fixes edge case bug with resolve path helper
Introduces general purpose helpers on the Space namespace
Adds global value lookup for injection mapping support: e.g:
@injector.map('my.awesome.Class').asSingleton()
Support old js engines that without Object.defineProperty support.
Fixes bug where onDependenciesReady
was only called once per prototype
Fixes bug where onDependenciesReady
was called more than once
Fixes bug where injected values were overwritten
Fixes bug where injected values were overwritten
Fixes regression bug where injector didn't inject into values
Renames Space.Class
to Space.Object
- Adds support for static constructor functions while extending classes
- Completes API compatibility to dependance injector
- Providers are now added to the
Mapping
prototype, not to every instance.
- Adds
Space.Object
for better Javascript inheritance support - Replaces Dependance with brand new (but compatible)
Space.Injector
Added mappings to core Meteor packages
Publish first version to Meteor package system
Initial release of Space