Linking keywords with sagas
A saga can be thought of as a special event handler that returns commands. Sagas do this by leveraging RxJS to receive and react to all events published to the event bus. Using the UpdateKeywordLinksEvent
event handler, we can logically partition the work into two separate commands: one to create keyword links and one to remove them. Since sagas return commands, the saga and command must be created in the same module. Otherwise, command module scoping will become a problem and Nest.js will throw an exception when our saga attempts to return a command found in a different module. To get started, we will need setup the commands and command handlers that will be replacing our single event handler.
Keyword saga commands
Just because we are using sagas to execute our new commands does not change how we write those commands and command handlers. We will split the UpdateKeywordLinksEvent
into two separate commands within the keyword module.
export
class
LinkKeywordEntryCommand...