Interactions are more fun when you can express yourself! Let users react using emojis, stickers, or thumbs up to messages.
To maximize engagement on the content of your application, you can use reactions on messages, posts, or comments. The reaction is similar to the Facebook Like. While a user can add many reactions to a model, it can only add each reaction one time only.
Each model which can be reacted upon will carry a set of properties useful to display its reactions. You will find:
reactions
: an object containing the name of the reactions as key, and their count as value (ex: { like: 1, love: 1 }
)
reactionCount
: the sum of all the counts for all the reactions
myReactions
: an array containing the current's users reactions
First, simply import the ReactorRepository
and pass in the message you want to react upon.
Then call for addReaction()
and pass along the identifier for your reaction.
Just as you did for adding a reaction, you can call removeReaction()
to remove a reaction.
Both addReaction()
and removeReaction()
methods return a Promise resolving a boolean acknowledging the server's successful response. If necessary, you can use await
to receive the result of those operations.