Conversation
…to practicalmeteor:mocha-core 1.0.0
|
This is not working, imports are import { BankAccountOpened, BankAccountCredited, BankAccountDebited } from '../../domain/events';Event definitions: import Contact from './value-objects/contact';
export default Space.messaging.define(Space.domain.Event, {
BankAccountOpened: {
owner: Contact,
initialBalance: Money,
overdraft: Money,
currency: Currency
},
BankAccountCredited: {
amount: Money
},
BankAccountDebited: {
amount: Money
}
});
Space.messaging.define = (BaseType, ...options) => {
if (!BaseType.isSerializable) {
throw new Error('BaseType must extend Space.messaging.Serializable');
}
let namespace = null;
let definitions = null;
let subTypes = {};
switch (options.length) {
case 0:
throw new Error(`Space.messaging.define is missing options for defining sub typs of ${BaseType}.`);
case 1:
if (_.isObject(options[0])) {
// VALID: Definitions but no namespace provided
namespace = '';
definitions = options[0];
} else {
throw new Error(`Space.messaging.define is missing definitions for ${BaseType}.`);
}
break;
default:
// VALID: Namespace and definitions provided
namespace = options[0].toString();
definitions = options[1];
break;
}
_.each(definitions, (fields, className) => {
let classPath = className;
if (namespace !== '') classPath = `${namespace}.${className}`;
let SubType = BaseType.extend(classPath);
SubType.prototype.fields = () => _.extend(BaseType.prototype.fields(), fields);
Space.resolvePath(namespace)[className] = SubType;
subTypes[classPath] = SubType;
});
return subTypes;
};Using those imports works because of global event definitions. |
|
@darko-mijic this is not how imports work. When you
and then access them like this:
or descructure them into the current scope like this:
|
|
I know, that is why i mentioned this and that is how we where using command and event definitions before. ;) We will go back to using imported objects with command and event definitions as properties unless @rhyslbw has a better idea. |
|
I like destructuring into the current scope for now for ease of refactoring at a later stage. I was just voicing the ideal that we should aim for when I made the earlier comment about importing named exports. |
…rectly with collection data
…ray has single value [{}]
…action needs to be used to update mobx managed state
Remove redux and refactor to mobx store and actions
|
@rhyslbw and @darko-mijic what is the current state of this PR? I don't like staying too long in single PRs which get bigger and bigger 😉 |


No description provided.