compose method

  1. @override
UIPayload? compose(
  1. UIPayload? a,
  2. UIPayload? b
)
override

Combines two payloads into a single payload. Returns null if both inputs are null.

Implementation

@override
UIPayload? compose(UIPayload? a, UIPayload? b) {
  if (a == null) return b;
  if (b == null) return a;

  final list = [
    if (a case UIPayloads(list: final list)) ...list else a,
    if (b case UIPayloads(list: final list)) ...list else b,
  ];
  if (list.length == 1) return list.first;
  return UIPayloads(list);
}