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

Swift Task Naming API #2619

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Harjas12
Copy link

No description provided.

@Harjas12 Harjas12 force-pushed the task-naming-api-proposal branch 2 times, most recently from 7f71aac to c0e0748 Compare November 19, 2024 03:04

```swift
extension Task {
var currentName: String? { get }
Copy link
Contributor

@ktoso ktoso Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var currentName: String? { get }
// read the name of a task instance, e.g. someTask.name
var name: String? { get }
// read the name of the current task, e.g. Task.name
static var currentName: String? { get }

)

mutating func addTaskUnlessCancelled(
name: String? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: String? = nil,
name: String?,


```swift
mutating func addTask(
name: String? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: String? = nil,
name: String?,

operation: sending @escaping @isolated(any) () async -> Success

static func detached(
name: String? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: String? = nil,
name: String?,


```swift
init(
name: String? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: String? = nil,
name: String?,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I may ask: is something you both would consider for the naming API to use an enum? I am asking this, because it would be also good to in case of having to iterate over the Tasks we may have, comparing them or even making using a switch. Of course, my suggestion is not to remove the String as a type for naming it, but having a second flexible way to deal with them.

What do you think?

```swift
init(
name: String? = nil,
priority: TaskPriority? = nil,
Copy link
Contributor

@ktoso ktoso Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
priority: TaskPriority? = nil,
executorPreference taskExecutor: (any TaskExecutor)? = nil,
priority: TaskPriority? = nil,


static func detached(
name: String? = nil,
priority: TaskPriority? = nil,
Copy link
Contributor

@ktoso ktoso Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
priority: TaskPriority? = nil,
executorPreference taskExecutor: (any TaskExecutor)? = nil,
priority: TaskPriority? = nil,

@ktoso
Copy link
Contributor

ktoso commented Nov 19, 2024

@Harjas12 I did some updates, please check and merge them :)

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.

3 participants