Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DelayAsyncSequence #16

Merged
merged 2 commits into from
Feb 25, 2022
Merged

DelayAsyncSequence #16

merged 2 commits into from
Feb 25, 2022

Conversation

reddavis
Copy link
Owner

let stream = AsyncStream<Int> { continuation in
    continuation.yield(0)
    continuation.yield(1)
    continuation.yield(2)
    continuation.finish()
}

let start = Date.now
for element in try await self.stream.delay(for: 0.5) {
    print("\(element) - \(Date.now.timeIntervalSince(start))")
}

// Prints:
// 0 - 0.5
// 1 - 1.0
// 2 - 1.5

# Conflicts:
#	Asynchrone.xcodeproj/project.pbxproj
@reddavis reddavis merged commit a05ac17 into main Feb 25, 2022
@reddavis reddavis deleted the feature/delay branch February 25, 2022 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant