forked from Blendman974/faceclaw
Port navigate and weather
This commit is contained in:
1 parent
2b3e068a23
commit
9e18745e53
33 files changed
+630
-60
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { type CurrentLocation } from './location-types'
|
||||
export { type CurrentLocation } from './location-types'
|
||||
declare const FaceclawLocationUpdates: any
|
||||
|
||||
/** Main-thread one-shot lookup, independent of navigation and compass managers. */
|
||||
export function getCurrentLocation(): Promise<CurrentLocation> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const provider = FaceclawLocationUpdates.new()
|
||||
provider.eventHandler = (json: string) => {
|
||||
try {
|
||||
const event = JSON.parse(json)
|
||||
if (event.error) reject(new Error(event.error))
|
||||
else resolve(event)
|
||||
} catch (error) { reject(error) }
|
||||
finally { provider.stop() }
|
||||
}
|
||||
provider.startOnce()
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user