Skip to content

Instantly share code, notes, and snippets.

View mattwagl's full-sized avatar

Matthias Wagler mattwagl

View GitHub Profile
@mattwagl
mattwagl / read.js
Created March 7, 2018 17:13
A wolkenkit client that reads and observes a read model.
api.lists.posts.readAndObserve({
where: { boardId: state.activeBoardId }
}).
started((posts, cancel) => {
// render our ui
}).
updated((posts, cancel) => {
// re-render our ui
});
@mattwagl
mattwagl / mount.js
Created March 7, 2018 17:09
A wolkenkit client that issues a command and awaits the appropriate event.
api.collaboration.board().mount({
title
}).
await('mounted', event => {
// Show success notification
});
@mattwagl
mattwagl / connect.js
Created March 7, 2018 17:02
A wolkenkit client connecting to a backend.
import wolkenkit from 'wolkenkit-client';
const api = await wolkenkit.connect({ host: 'local.wolkenkit.io', port: 3000 });
@mattwagl
mattwagl / boards.js
Last active July 25, 2018 08:25
Simple wolkenkit readModel.
const projections = {
'collaboration.board.mounted' (boards, event) {
boards.add({
title: event.data.title,
slug: event.data.slug,
timestamp: event.metadata.timestamp
});
}
};
@mattwagl
mattwagl / board.js
Last active July 25, 2018 08:27
Simple wolkenkit writeModel.
const initialState = {
title: undefined,
slug: undefined
};
const commands = {
mount (board, command) {
if (command.data.title === undefined) {
command.reject('Title is missing.');
@mattwagl
mattwagl / readModel_lists_boards.js
Last active June 25, 2018 10:26
wolkenkit sample application.
const when = {
'collaboration.board.mounted' (boards, event, mark) {
boards.add({
title: event.data.title,
slug: event.data.slug,
timestamp: event.metadata.timestamp
});
mark.asDone();
}
@mattwagl
mattwagl / arrow-button.css
Created April 16, 2015 19:31
An arrow button in pure CSS.
.arrow-button {
background: #555;
background: linear-gradient(-135deg, transparent 22px, #555 0) top right,
linear-gradient(-45deg, transparent 22px, #555 0) bottom right;
background-size: 100% 50%;
background-repeat: no-repeat;
font-family: helvetica;
padding: 10px;
font-size:20px;
color: #fff;