take method

RxComputed<T?> take(
  1. int count
)

Take the first n values, returns null once exhausted. Always accesses value so dependency tracking is maintained, ensuring re-evaluation when the source changes.

Implementation

RxComputed<T?> take(int count) {
  int taken = 0;
  return computed(() {
    final current = value; // Always access to maintain dependency tracking
    if (taken < count) {
      taken++;
      return current;
    }
    return null;
  });
}