notify method

StubbleResult? notify(
  1. NotifyMessage msg,
  2. StubbleContext context
)

Implementation

StubbleResult? notify(NotifyMessage msg, StubbleContext context) {
  switch (msg.type) {
    case notifyConditionResult:
      _res = msg.value ?? false;

      if (msg.charCode != null) {
        return StubbleResult(
          message: ProcessMessage(
            charCode: msg.charCode!,
          ),
        );
      }

      break;
    case notifySecondCloseBracketFound:
      return StubbleResult(
        state: GetBlockEndState(
          blockName: 'if',
        ),
      );

    case notifyBlockEndResult:
      _body = msg.value;
      return result(context);

    default:
      return StubbleResult(
        err: StubbleError(
          code: errorUnsupportedNotify,
          text:
              'State "$runtimeType" does not support notifies of type ${msg.type}',
        ),
      );
  }

  return null;
}