Skip to content

Support Task.sleep(for:) with Duration parameter #38

Closed

Description

@d-date

Summary

Task.sleep(for: .seconds(N)) (the Duration-based overload from Swift 5.7+) is not yet available in Skip and produces a transpilation error:

error: This API is not yet available in Skip. Consider placing it within a #if !SKIP block.
        try? await Task.sleep(for: .seconds(30))
                        ^~~~~

Current workaround

Using the older nanoseconds-based API:

// Instead of:
try? await Task.sleep(for: .seconds(30))

// Use:
try? await Task.sleep(nanoseconds: 30_000_000_000)

Expected behavior

Task.sleep(for:) with Duration parameter should be transpiled to the equivalent Kotlin coroutine delay, similar to how Task.sleep(nanoseconds:) is handled.

Context

Encountered while building a periodic timer in an @Observable ViewModel for an Android app transpiled with Skip.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions