This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wolkenkit from 'wolkenkit-client'; | |
const api = await wolkenkit.connect({ host: 'local.wolkenkit.io', port: 3000 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api.collaboration.board().mount({ | |
title | |
}). | |
await('mounted', event => { | |
// Show success notification | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api.lists.posts.readAndObserve({ | |
where: { boardId: state.activeBoardId } | |
}). | |
started((posts, cancel) => { | |
// render our ui | |
}). | |
updated((posts, cancel) => { | |
// re-render our ui | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const when = { | |
'collaboration.board.mounted' (boards, event, mark) { | |
boards.add({ | |
title: event.data.title, | |
slug: event.data.slug, | |
timestamp: event.metadata.timestamp | |
}); | |
mark.asDone(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const projections = { | |
'collaboration.board.mounted' (boards, event) { | |
boards.add({ | |
title: event.data.title, | |
slug: event.data.slug, | |
timestamp: event.metadata.timestamp | |
}); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
title: undefined, | |
slug: undefined | |
}; | |
const commands = { | |
mount (board, command) { | |
if (command.data.title === undefined) { | |
command.reject('Title is missing.'); | |