Updating an application
To update an application to the current version of wolkenkit follow the steps given below.
package.json
Previous version (1.2.0)
"wolkenkit": {
"application": "your-app",
"runtime": {
"version": "1.2.0"
},
"...": "..."
}
Current version (2.0.0)
"wolkenkit": {
"application": "your-app",
"runtime": {
"version": "2.0.0"
},
"...": "..."
}
Write model, defining commands
Previous version (1.2.0)
const commands = {
send (message, command, mark) {
if (...) {
return mark.asRejected('Failed to send message.');
}
// ...
mark.asDone();
}
};
Current version (2.0.0)
const commands = {
async send (message, command) {
if (...) {
return command.reject('Failed to send message.');
}
// ...
}
};
Please note that you can omit the async
keyword if you don't use asynchronous code in your command. For details see defining commands.
Write model, using command middleware
Previous version (1.2.0)
const commands = {
send: [
(message, command, mark) => {
if (...) {
return mark.asRejected('Failed to validate message.');
}
// ...
mark.asReadyForNext();
},
(message, command, mark) => {
if (...) {
return mark.asRejected('Failed to send message.');
}
// ...
mark.asDone();
}
]
};
Current version (2.0.0)
const commands = {
send: [
async (message, command) => {
if (...) {
return command.reject('Failed to validate message.');
}
// ...
},
async (message, command) => {
if (...) {
return command.reject('Failed to send message.');
}
// ...
}
]
};
Please note that you can omit the async
keyword if you don't use asynchronous code in your middleware. For details see using command middleware.
Write model, using services
Previous version (1.2.0)
const commands = {
send (message, command, services, mark) {
const app = services.get('app');
// ...
mark.asDone();
}
};
Current version (2.0.0)
const commands = {
async send (message, command, { app }) {
// ...
}
};
For details see using command services.
Read model, defining projections
Previous version (1.2.0)
const when = {
'communication.message.sent' (messages, event, mark) {
// ...
mark.asDone();
}
};
Current version (2.0.0)
const projections = {
async 'communication.message.sent' (messages, event) {
// ...
}
};
Please note that you can omit the async
keyword if you don't use asynchronous code in your projections. For details see defining projections.
Read model, using services
Previous version (1.2.0)
const when = {
'communication.message.sent' (messages, event, services, mark) {
const app = services.get('app');
// ...
mark.asDone();
}
};
Current version (2.0.0)
const projections = {
'communication.message.sent' (messages, event, { app }) {
// ...
}
};
For details see using services.
Stateless flows, reacting to events
Previous version (1.2.0)
const when = {
'communication.message.sent' (event, mark) {
// ...
mark.asDone();
}
};
Current version (2.0.0)
const reactions = {
async 'communication.message.sent' (event) {
// ...
}
};
Please note that you can omit the async
keyword if you don't use asynchronous code in your reaction. For details see reacting to events.
Stateless flows, using services
Previous version (1.2.0)
const when = {
'communication.message.sent' (event, services, mark) {
const app = services.get('app');
// ...
mark.asDone();
}
};
Current version (2.0.0)
const reactions = {
'communication.message.sent' (event, { app }) {
// ...
}
};
For details see using services.
Stateful flows, reacting to state transitions
Previous version (1.2.0)
const when = {
pristine: {
'awaiting-payment' (flow, event, mark) {
// ...
mark.asDone();
}
}
};
Current version (2.0.0)
const reactions = {
pristine: {
async 'awaiting-payment' (flow, event) {
// ...
}
}
};
Please note that you can omit the async
keyword if you don't use asynchronous code in your reaction. For details see reacting to state transitions.
Stateful flows, using services
Previous version (1.2.0)
const when = {
pristine: {
'communication.message.sent' (flow, event, services, mark) {
const app = services.get('app');
// ...
mark.asDone();
}
}
};
Current version (2.0.0)
const reactions = {
pristine: {
'communication.message.sent' (flow, event, { app }) {
// ...
}
}
};
For details see using services.
Client
Up to wolkenkit 1.2.0, instead of loading the wolkenkit SDK by using the require
function, you could use a <script>
tag in your index.html
file. wolkenkit 2.0.0 does not support loading the SDK using a <script>
tag any more.
So now you must use the require
function to load the wolkenkit SDK, no matter whether you are on Node.js or you are writing an application for the browser:
const wolkenkit = require('wolkenkit-client');
This means that when developing for the browser you have to use a bundler such as webpack. For details see connecting to an application.