applyEvent method

dynamic applyEvent(
  1. String userId,
  2. ModelChanged event
)

Implementation

applyEvent(String userId, ModelChanged event) async {
  for (var action in event.actions) {
    if (!persistances.contains(action.model)) {
      continue;
    }
    switch (action.action) {
      case ModelAction.deleted:
        await _delete(action.model, action, userId);
      case ModelAction.updated:
        await _update(action.model, action, userId);
      case ModelAction.created:
        await _create(action.model, action, userId);
      default:
      // warning here
    }
  }
}