<commit_before>eventric = require "eventric"

feedContext = eventric.context("Feed")


feedContext.defineDomainEvents
  FeedCreated: (params) ->

  FeedCaptionChanged: (params) ->
    @caption = params.caption


feedContext.addAggregate "Feed", ->
  @create = (params, callback) ->
    @$emitDomainEvent "FeedCreated"
    @changeCaption params.caption  if params.caption
    callback()

  @changeCaption = (caption) ->
    @$emitDomainEvent "FeedCaptionChanged",
      caption: caption
  return


feedContext.addCommandHandler "CreateFeed", (params, done) ->
  @$aggregate.create("Feed", params).then((feed) ->
    feed.$save()<commit_msg>Add TestCommand to FeedContext<commit_after>eventric = require "eventric"

feedContext = eventric.context("Feed")


feedContext.defineDomainEvents
  FeedCreated: (params) ->

  FeedCaptionChanged: (params) ->
    @caption = params.caption


feedContext.addAggregate "Feed", ->
  @create = (params, callback) ->
    @$emitDomainEvent "FeedCreated"
    @changeCaption params.caption  if params.caption
    callback()

  @changeCaption = (caption) ->
    @$emitDomainEvent "FeedCaptionChanged",
      caption: caption
  return


feedContext.addCommandHandler "TestCommand", (params, done) ->
  console.log "---------------- TestCommand ----------------"


feedContext.addCommandHandler "CreateFeed", (params, done) ->
  @$aggregate.create("Feed", params).then((feed) ->
    feed.$save()
{'fraction_non_alphanumeric': 0.15330520393811534, 'fraction_numerical': 0.0, 'mean_word_length': 3.9409722222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6173933', 'n_tokens_mistral': 436, 'n_tokens_neox': 415, 'n_words': 84}