WIP
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import {emitGeoUpdated} from '#/state/events'
|
||||||
|
|
||||||
|
let geo: any
|
||||||
|
|
||||||
|
export async function resolveGeo() {
|
||||||
|
const req = new Promise(y => {
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
geo = {country_code: 'US'}
|
||||||
|
emitGeoUpdated({geo})
|
||||||
|
} catch (e) {
|
||||||
|
} finally {
|
||||||
|
y(0)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!geo) {
|
||||||
|
await req
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getGeo() {
|
||||||
|
return geo
|
||||||
|
}
|
||||||
@@ -45,3 +45,11 @@ export function listenPostCreated(fn: () => void): UnlistenFn {
|
|||||||
emitter.on('post-created', fn)
|
emitter.on('post-created', fn)
|
||||||
return () => emitter.off('post-created', fn)
|
return () => emitter.off('post-created', fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emitGeoUpdated({geo}: {geo: any}) {
|
||||||
|
emitter.emit('geo-updated', geo)
|
||||||
|
}
|
||||||
|
export function listenGeoUpdated(fn: ({geo}: {geo: any}) => void): UnlistenFn {
|
||||||
|
emitter.on('geo-updated', fn)
|
||||||
|
return () => emitter.off('geo-updated', fn)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user