How to extract double from parameter? #99
-
I have a set of routes that have approximately this shape to them extension AppRoute {
enum ActionsRoute {
case copy
case sync(timestamp: Int)
}
} What I really want though is static let router = OneOf {
Route(.case(AppRoute.ActionsRoute.copy)) {
Path { "copy" }
Query {
Field("item") { "id" }
}
}
Route(.case(AppRoute.ActionsRoute.sync)) {
Path { "sync" }
Query {
Field("from", default: Int(Date.now.timeIntervalSince1970)) { Digits() }
}
}
}
@MainActor
func handleDeepLink(_ route: AppRoute.ActionsRoute) {
switch route {
case .copy:
// Implementation here
case .sync(let timestamp):
let timeInterval = Double(timestamp)
let date = Date(timeIntervalSince1970: timeInterval)
// Sync from the date above
}
} I've gone through the code and documentation but couldn't figure out how to properly format the query parameter to use a Thank you so much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Have you tried |
Beta Was this translation helpful? Give feedback.
Have you tried
Double.parser()
instead ofDigits()
?