This major version has been months in the works, and we're excited to be introducing Version 6 as a simplification of APIs and separation of concerns.
With this release we see flux concepts extracted into a dedicated package space:flux, allowing space:ui
to provide pattern-agnostic UI base features suitable for tailored implementations. Installing space:flux
will install space:ui
, but if flux or our implementation is not what you're looking for, just use space:ui
instead. Too easy!
We're now 100% focused on ES6, and have introduced declarative APIs as the original Coffeescript style didn't translate well. View the complete TodoMVC example here to get a feel for the new style
State APIs have been unified into Space.ui.Stateful
; an object added as a mixin. There are three types of state it can manage:
-
- You already have a reactive data source like
Mongo.Collection::find
: in this case you simply create methods on the class that return these:
- You already have a reactive data source like
Space.flux.Store.extend(TodoMVC, 'TodosStore', {
completedTodos: function() {
return this.todos.find({ isCompleted: true });
}
});
-
- If you need to manage state that you don't want to hold in a collection
you can use the new API to generate
ReactiveVar
instance accessors:
- If you need to manage state that you don't want to hold in a collection
you can use the new API to generate
Space.flux.Store.extend(TodoMVC, 'TodosStore', {
reactiveVars: function() {
return [{
activeFilter: this.FILTERS.ALL,
}];
},
filteredTodos: function() {
// Depend on the reactive value to choose a todos filter
switch (this.activeFilter()) {
case this.FILTERS.ALL: return this.todos.find();
case this.FILTERS.ACTIVE: return this.todos.find({ isCompleted: false});
case this.FILTERS.COMPLETED: return this.todos.find({ isCompleted: true });
}
},
_changeActiveFilter: function(event) {
// Set the reactive var to a new value
this.activeFilter(event.filter);
}
});
-
- If you need to manage state that you don't want to hold in a collection, and you need the values to persist during a hot-code push use the new sessionVars API to generate a scoped
ReactiveDict
instance accessor:
- If you need to manage state that you don't want to hold in a collection, and you need the values to persist during a hot-code push use the new sessionVars API to generate a scoped
Space.flux.Store.extend(TodoMVC, 'TodosStore', {
sessionVars() {
return [{
editingTodoId: null
}];
},
eventSubscriptions() {
return [{
'TodoMVC.TodoEditingStarted': this._setEditingTodoId,
'TodoMVC.TodoEditingEnded': this._unsetEditingTodoId,
}];
},
_setEditingTodoId(event) {
this._setSessionVar('editingTodoId', event.todoId);
},
_unsetEditingTodoId() {
this._setSessionVar('editingTodoId', null);
}
});
Space.ui.BlazeComponent
is Stateful
Space.ui.BlazeComponent.extend('TodoMVC.MyCustomComponent', {
_session: 'TodoMVC.MyCustomComponent', // some unique name for session
sessionVars() {
return [{ mySessionVar: null }]; // default value
},
reactiveVars() {
return [{ someReactiveVar: null }]; // default value
}
});
Space.ui.Event
is an extension ofSpace.messaging.Event
Currently this is just a more expressive object, but any future UI specific event features will be added here and not the base class.
-
This version uses space:base 4.x which includes breaking changes. Please see the changelog.
-
This version uses space:messaging 3.x which includes breaking changes. Please see the changelog.
-
Must be running Meteor 1.2.0.1 or later.
-
Space.ui.Store
has been extracted to a separate package space:flux -
Reactive data sources now just need to be defined as methods on
Space.flux.Store
, with non-reactive sources returned inreactiveVars
orsessionVars
. This change was motivated to simplify the component's interface, but it also improves the clarity of reactive state management in the store. -
Space.ui.Mediator
was removed from the project in favour of more popular and recommended alternatives like blaze-components.
-
Please see the migration guide in space:base
-
meteor add space:flux
-
Switch base object
Space.ui.Store
toSpace.flux.Store
-
Replace any
Space.ui.Mediator
and standard 'template managers' with aSpace.ui.BlazeComponent
(Example: TodoList component) -
Change all
Space.flux.Store
event subscribers to the new declarativeeventSubscriptions
API. -
Ensure all store state is either determined via a method (if already reactive), or is part of
reactiveVars
orsessionVars
(a store scoped reactiveDict).
Further detail can be seen in TodosMVC sample app
Updates to latest space:base
and space:messaging
packages.
Updated Github location to point to new home at https://github.com/meteor-space/ui
Updates to latest space:base
and space:messaging
packages which introduced
many small debugging and API improvements.
Throw better errors when blaze components could not be resolved.
Let mediators and blaze components cleanup their state on destruction
Adds weak dependency on blaze-components package so that it work in a package only app.
Introduces support for blaze-components
via the new class Space.ui.BlazeComponent
. This works very similar to Space.ui.Mediator
but it also extends BlazeComponent
with all its capabilities.
See the TodoMVC example for a basic reference.
Adds support for Meteor > 1.0 template hooks.
@Sanjo fixed a minor issue #29 with Space.ui.createEvents
Updates to space:[email protected]
and space:[email protected]
(checkout breaking
changes in both packages!). Here is short summary:
- replace the app/module
run
hook withstartup
- start your application with
start
instead ofrun
- There is a new
Space.messaging.Api
to define Meteor methods that can be tested easily. This replaces the functionality fromSpace.messaging.CommandBus
to send commands from client to server. This is not possible anymore! Commands are now just the same as events, you can use them on the client side and server side the same way, BUT if you want "type safety" when sending a command from client to server, you have to check it yourself within the server method. See the updated TodoMVC example.
Introduces the concept of non-reactive default state for stores and mediators
so that state is not always overwritten by default values when some reactive
dependency triggers a re-run of the setInitialState
method. If you have default
values for the state use setDefaultState
instead. This method is only run once
when the instance is created, after the dependencies were injected.
Make setting the initial state of stores and mediators reactive. This has the
benefit that one can take advantage of Mongo.Collection#findOne
and other reactivity
features when initializing the state.
Use the new Space.Object.mixin
capabilities to introduce the Space.ui.Stateful
mixin that encapsulates the state setting functionality that the store had and make
it available on mediators too.
Introduce Space.ui.Module with same mapping automation features as the previously added Space.ui.Application
Updates to latest space package dependencies, especially to space:messaging
which introduced a simpler controller api for handling messages.
Fixes bug with reactivity when setting store state via set
. It is non-reactive now.
Adds Space.ui.Application
class with simplified api for setting up stores,
mediators and controllers.
Use latest space:messaging release
- Upgrades to
space:[email protected]
Replace the flux dispatcher and actions with more solid event architecture
called space:messaging
. This also introduces type-checked events. Please
have a look at the TodoMVC example to see how the new system works.
Upgrades to space:[email protected]
Adds tests for store state
related methods and improves its API
Upgrades to space:[email protected]
Removes iron-router suppport and its dependency on it.
Improves the Mediator api for creating template helpers and event handlers.
Adds simplified api for creating and dispatching actions (see TodoMVC example).
Introduces auto-mapping of mediators and templates via annotations.
Cleans up the mediator API and removed old relicts that are not used anymore.
Update to the latest 1.0.3 verison of iron:router and fast-render packages.
Publish first version to Meteor package system.