Core Library0.xAPI reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

method libtmux-swift

ControlNotificationStream.drop(while:)

Omits elements from the base asynchronous sequence until a given closure returns false, after which it passes through all remaining elements.

Source and package
Qualified name
ControlNotificationStream.drop(while:)
Declared in
ControlNotificationStream
Package
libtmux-swift
drop(while: (Self.Element) async -> Bool) -> AsyncDropWhileSequence<Self>

Inherited from AsyncSequence.drop(while:)

Description

Use drop(while:) to omit elements from an asynchronous sequence until the element received meets a condition you specify.

In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The drop(while:) method causes the modified sequence to ignore received values until it encounters one that is divisible by 3:

let stream = Counter(howHigh: 10) .drop { $0 % 3 != 0 } for await number in stream { print(number, terminator: " ") } // Prints "3 4 5 6 7 8 9 10 "

After the predicate returns false, the sequence never executes it again, and from then on the sequence passes through elements from its underlying sequence as-is.

  • Parameter predicate: A closure that takes an element as a parameter and returns a Boolean value indicating whether to drop the element from the modified sequence.
  • Returns: An asynchronous sequence that skips over values from the base sequence until the provided closure returns false.
Parameters

Recorded calls

source calls
No call edges in the Swift model.

The Swift reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls ControlNotificationStream.drop(while:).

Esc
Search in

Type to search.

Reference previewOpen reference