0.34.3 • Published 2 years ago
@resolve-js/module-comments v0.34.3
@resolve-js/module-comments
Usage
import { merge } from '@resolve-js/scripts'
import createModuleComments from '@resolve-js/module-comments'
merge(resolveConfig, createModuleComments())
Customization of module options
import { merge } from '@resolve-js/scripts'
import createModuleComments from '@resolve-js/module-comments'
merge(
resolveConfig,
createModuleComments({
aggregateName: 'CustomCommentsAggregateName', // default = 'Comments'
readModelName: 'CustomCommentsReadModelName', // default = 'Comments'
readModelConnector: {
module: 'CustomreadModelConnector', // default = @resolve-js/readmodel-lite'
options: {}, // default = {}
},
commentsTableName: 'CustomCommentsTableName', // default = 'Comments'
reducerName: 'CustomReducerName', // default = 'comments'
eventTypes: {
COMMENT_CREATED: 'CUSTOM_COMMENT_CREATED', // default = 'COMMENT_CREATED'
COMMENT_UPDATED: 'CUSTOM_COMMENT_UPDATED', // default = 'COMMENT_UPDATED'
COMMENT_REMOVED: 'CUSTOM_COMMENT_REMOVED', // default = 'COMMENT_REMOVED'
},
commandTypes: {
createComment: 'customCreateComment', // default = 'createComment'
updateComment: 'customUpdateComment', // default = 'updateComment'
removeComment: 'customRemoveComment', // default = 'removeComment'
},
resolverNames: {
commentsTree: 'customCommentsTree', // default = 'commentsTree',
foreignCommentsCount: 'customForeignCommentsCount', // default = 'foreignCommentsCount',
allCommentsPaginate: 'customAllCommentsPaginate', // default = 'allCommentsPaginate'
},
maxNestedLevel: 2, // default = undefined
verifyCommand: path.join(__dirname, 'customVerifyCommand.js'), // default = '@resolve-js/module-comments/lib/aggregates/verify-command.js'
})
)
Customization of verifyCommand
// customVerifyCommand.js
const verifyCommand = async (state, command, jwt) => {
// ...
}
export default verifyCommand
Commands
createComment(aggregateId, {
authorId,
commentId,
parentCommentId,
content,
})
updateComment(aggregateId, {
authorId,
commentId,
content,
})
removeComment(aggregateId, {
authorId,
commentId,
})
Renderless Connectors
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>
)
0.34.3
2 years ago
0.34.2
2 years ago
0.34.1
2 years ago
0.34.0
2 years ago
0.33.10
2 years ago
0.33.15
2 years ago
0.33.14
2 years ago
0.33.13
2 years ago
0.33.12
2 years ago
0.33.9
2 years ago
0.33.11
2 years ago
0.33.7
2 years ago
0.33.6
2 years ago
0.33.5
2 years ago
0.33.4
2 years ago
0.33.3
2 years ago
0.33.2
2 years ago
0.33.1
3 years ago
0.33.8
2 years ago
0.33.0
3 years ago
0.32.0
3 years ago
0.31.10
3 years ago
0.31.9
3 years ago
0.31.8
3 years ago
0.31.7
3 years ago
0.31.6
3 years ago
0.31.5
3 years ago
0.31.4
3 years ago
0.31.3
3 years ago
0.31.2
3 years ago
0.31.1
3 years ago
0.31.0
3 years ago
0.30.5
3 years ago
0.30.4
3 years ago
0.30.3
3 years ago
0.30.2
3 years ago
0.30.1
3 years ago
0.30.0
3 years ago
0.29.0
3 years ago
0.28.3
3 years ago
0.28.1-alpha
3 years ago
0.28.2
3 years ago
0.28.0-alpha.2
3 years ago
0.28.0-alpha.1
3 years ago