
import { merge } from '@resolve-js/scripts'
import createModuleComments from '@resolve-js/module-comments'
merge(resolveConfig, createModuleComments())
import { merge } from '@resolve-js/scripts'
import createModuleComments from '@resolve-js/module-comments'
merge(
resolveConfig,
createModuleComments({
aggregateName: 'CustomCommentsAggregateName',
readModelName: 'CustomCommentsReadModelName',
readModelConnector: {
module: 'CustomreadModelConnector',
options: {},
},
commentsTableName: 'CustomCommentsTableName',
reducerName: 'CustomReducerName',
eventTypes: {
COMMENT_CREATED: 'CUSTOM_COMMENT_CREATED',
COMMENT_UPDATED: 'CUSTOM_COMMENT_UPDATED',
COMMENT_REMOVED: 'CUSTOM_COMMENT_REMOVED',
},
commandTypes: {
createComment: 'customCreateComment',
updateComment: 'customUpdateComment',
removeComment: 'customRemoveComment',
},
resolverNames: {
commentsTree: 'customCommentsTree',
foreignCommentsCount: 'customForeignCommentsCount',
allCommentsPaginate: 'customAllCommentsPaginate',
},
maxNestedLevel: 2,
verifyCommand: path.join(__dirname, 'customVerifyCommand.js'),
})
)
const verifyCommand = async (state, command, jwt) => {
}
export default verifyCommand

createComment(aggregateId, {
authorId,
commentId,
parentCommentId,
content,
})
updateComment(aggregateId, {
authorId,
commentId,
content,
})
removeComment(aggregateId, {
authorId,
commentId,
})
import React from 'react'
import {
CommentsTreeRenderless,
CommentsPaginateRenderless,
CommentsNotificationRenderless,
RefreshHelperRenderless,
} from '@resolve-js/module-comments'
export const CommentsTree = (props) => (
<CommentsTreeRenderless
treeId="treeId"
parentCommentId="parentCommentId"
authorId="authorId"
>
{({ comments, createComment, renameComment, removeComment }) => {
// eslint-disable-next-line
console.log('comments:', comments)
return null
}}
</CommentsTreeRenderless>
)
export const CommentsPaginate = ({ itemsOnPage }) => (
<CommentsPaginateRenderless
itemsOnPage
pageNumber
readModelName="customReadModelName" // default = 'readModelName'
resolverName="customAllCommentsPaginate" // default = 'allCommentsPaginate'
>
{({ pageNumber, comments }) => {
// eslint-disable-next-line
console.log(
`comments (pageNumber: ${pageNumber}, itemsOnPage: ${itemsOnPage}):`,
comments
)
return null
}}
</CommentsPaginateRenderless>
)
export const CommentsNotification = (props) => (
<CommentsNotificationRenderless
treeId="treeId"
parentCommentId="parentCommentId"
authorId="authorId"
readModelName="customReadModelName" // default = 'readModelName'
resolverName="customResolverName" // default = 'foreignCommentsCount'
{...props}
>
{({ count, onClick }) => {
if (count === 0) return null
return (
<div onClick={onClick}>
Comments have been updated - refresh page to see them
</div>
)
}}
</CommentsNotificationRenderless>
)
export const RefreshHelper = () => (
<RefreshHelperRenderless>
{({ refreshId, refresh }) => <div onClick={refresh}>{refreshId}</div>}
</RefreshHelperRenderless>
)