From 08864a0ef0823c53e7c098a0701096bb4d6efc26 Mon Sep 17 00:00:00 2001 From: Red Davis Date: Fri, 7 Jan 2022 17:59:10 +0000 Subject: [PATCH] Add CurrentElementAsyncSequence (#9) * Add CurrentElementAsyncSequence * Update readme * Update documentation --- .documentation/Actors.html | 189 ++++++++ .../Actors/CurrentElementAsyncSequence.html | 437 ++++++++++++++++++ .documentation/Extensions.html | 8 + .documentation/Extensions/AsyncSequence.html | 8 + .documentation/Extensions/AsyncStream.html | 8 + .../Extensions/AsyncStream/Continuation.html | 8 + .../Extensions/AsyncThrowingStream.html | 8 + .../AsyncThrowingStream/Continuation.html | 8 + .documentation/Structs.html | 10 +- .../Structs/AnyAsyncSequenceable.html | 8 + .../Structs/AnyThrowingAsyncSequenceable.html | 8 + .../Structs/CombineLatest3AsyncSequence.html | 8 + .../Structs/CombineLatestAsyncSequence.html | 8 + .../Structs/DebounceAsyncSequence.html | 8 + .documentation/Structs/Fail.html | 8 + .documentation/Structs/Just.html | 8 + .../Structs/Merge3AsyncSequence.html | 8 + .../Structs/MergeAsyncSequence.html | 8 + .../Structs/PassthroughAsyncSequence.html | 8 + .../RemoveDuplicatesAsyncSequence.html | 8 + .../Structs/ReplaceErrorAsyncSequence.html | 8 + .../Structs/SharedAsyncSequence.html | 18 +- .../Structs/ThrottleAsyncSequence.html | 8 + .../ThrowingPassthroughAsyncSequence.html | 8 + .documentation/Structs/Zip3AsyncSequence.html | 8 + .documentation/Structs/ZipAsyncSequence.html | 8 + .../Contents/Resources/Documents/Actors.html | 189 ++++++++ .../Actors/CurrentElementAsyncSequence.html | 437 ++++++++++++++++++ .../Resources/Documents/Extensions.html | 8 + .../Documents/Extensions/AsyncSequence.html | 8 + .../Documents/Extensions/AsyncStream.html | 8 + .../Extensions/AsyncStream/Continuation.html | 8 + .../Extensions/AsyncThrowingStream.html | 8 + .../AsyncThrowingStream/Continuation.html | 8 + .../Contents/Resources/Documents/Structs.html | 10 +- .../Structs/AnyAsyncSequenceable.html | 8 + .../Structs/AnyThrowingAsyncSequenceable.html | 8 + .../Structs/CombineLatest3AsyncSequence.html | 8 + .../Structs/CombineLatestAsyncSequence.html | 8 + .../Structs/DebounceAsyncSequence.html | 8 + .../Resources/Documents/Structs/Fail.html | 8 + .../Resources/Documents/Structs/Just.html | 8 + .../Structs/Merge3AsyncSequence.html | 8 + .../Documents/Structs/MergeAsyncSequence.html | 8 + .../Structs/PassthroughAsyncSequence.html | 8 + .../RemoveDuplicatesAsyncSequence.html | 8 + .../Structs/ReplaceErrorAsyncSequence.html | 8 + .../Structs/SharedAsyncSequence.html | 18 +- .../Structs/ThrottleAsyncSequence.html | 8 + .../ThrowingPassthroughAsyncSequence.html | 8 + .../Documents/Structs/Zip3AsyncSequence.html | 8 + .../Documents/Structs/ZipAsyncSequence.html | 8 + .../Contents/Resources/Documents/index.html | 27 +- .../Contents/Resources/Documents/search.json | 2 +- .../.docset/Contents/Resources/docSet.dsidx | Bin 45056 -> 45056 bytes .documentation/docsets/.tgz | Bin 99845 -> 102641 bytes .documentation/index.html | 27 +- .documentation/search.json | 2 +- Asynchrone.xcodeproj/project.pbxproj | 8 + .../CurrentElementAsyncSequence.swift | 112 +++++ .../CurrentElementAsyncSequenceTests.swift | 40 ++ README.md | 20 + 62 files changed, 1882 insertions(+), 16 deletions(-) create mode 100644 .documentation/Actors.html create mode 100644 .documentation/Actors/CurrentElementAsyncSequence.html create mode 100644 .documentation/docsets/.docset/Contents/Resources/Documents/Actors.html create mode 100644 .documentation/docsets/.docset/Contents/Resources/Documents/Actors/CurrentElementAsyncSequence.html create mode 100644 Asynchrone/Source/Sequence/CurrentElementAsyncSequence.swift create mode 100644 AsynchroneTests/CurrentElementAsyncSequenceTests.swift diff --git a/.documentation/Actors.html b/.documentation/Actors.html new file mode 100644 index 0000000..dc4d947 --- /dev/null +++ b/.documentation/Actors.html @@ -0,0 +1,189 @@ + + + + Actors Reference + + + + + + + + + + + + + +
+
+

Docs (99% documented)

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Actors

+

The following actors are available globally.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    A async sequence that wraps a single value and emits a new element whenever the element changes.

    +
    let sequence = CurrentElementAsyncSequence(0)
    +print(await sequence.element)
    +
    +await stream.yield(1)
    +print(await sequence.element)
    +
    +await stream.yield(2)
    +await stream.yield(3)
    +await stream.yield(4)
    +print(await sequence.element)
    +
    +// Prints:
    +// 0
    +// 1
    +// 4
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public actor CurrentElementAsyncSequence<Element> : AsyncSequence
    + +
    +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/.documentation/Actors/CurrentElementAsyncSequence.html b/.documentation/Actors/CurrentElementAsyncSequence.html new file mode 100644 index 0000000..f1dc02d --- /dev/null +++ b/.documentation/Actors/CurrentElementAsyncSequence.html @@ -0,0 +1,437 @@ + + + + CurrentElementAsyncSequence Actor Reference + + + + + + + + + + + + + +
+
+

Docs (99% documented)

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CurrentElementAsyncSequence

+
+
+ +
public actor CurrentElementAsyncSequence<Element> : AsyncSequence
+ +
+
+

A async sequence that wraps a single value and emits a new element whenever the element changes.

+
let sequence = CurrentElementAsyncSequence(0)
+print(await sequence.element)
+
+await stream.yield(1)
+print(await sequence.element)
+
+await stream.yield(2)
+await stream.yield(3)
+await stream.yield(4)
+print(await sequence.element)
+
+// Prints:
+// 0
+// 1
+// 4
+
+ +
+
+
+
    +
  • +
    + + + + element + +
    +
    +
    +
    +
    +
    +

    The element wrapped by this async sequence, emitted as a new element whenever it changes.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public private(set) var element: Element { get }
    + +
    +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

Initialization +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an async sequence that emits elements only after a specified time interval elapses between emissions.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ element: Element)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + element + + +
    +

    The async sequence in which this sequence receives it’s elements.

    +
    +
    +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

AsyncSequence +

+
+
+
    +
  • +
    + + + + makeAsyncIterator() + +
    +
    +
    +
    +
    +
    +

    Creates an async iterator that emits elements of this async sequence.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    nonisolated public func makeAsyncIterator() -> AsyncStream<Element>.Iterator
    + +
    +
    +
    +

    Return Value

    +

    An instance that conforms to AsyncIteratorProtocol.

    +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

API +

+
+
+
    +
  • +
    + + + + yield(_:) + +
    +
    +
    +
    +
    +
    +

    Yield a new element to the sequence.

    + +

    Yielding a new element will update this async sequence’s element property +along with emitting it through the sequence.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func yield(_ element: Element)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + element + + +
    +

    The element to yield.

    +
    +
    +
    +
    +
    +
  • +
  • +
    + + + + finish() + +
    +
    +
    +
    +
    +
    +

    Mark the sequence as finished by having it’s iterator emit nil.

    + +

    Once finished, any calls to yield will result in no change.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func finish()
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + finish(with:) + +
    +
    +
    +
    +
    +
    +

    Emit one last element beford marking the sequence as finished by having it’s iterator emit nil.

    + +

    Once finished, any calls to yield will result in no change.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func finish(with element: Element)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + element + + +
    +

    The element to emit.

    +
    +
    +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/.documentation/Extensions.html b/.documentation/Extensions.html index e520367..d43f433 100644 --- a/.documentation/Extensions.html +++ b/.documentation/Extensions.html @@ -35,6 +35,14 @@