@ exodus/ 地理
与其他模块不同,这个模块仅导出原子,因为地理定位只是读取的数据源,模块本身没有任何动作,也不应该直接被消耗.
使用量
import geolocationMonitorDefinition from '@exodus/geolocation/monitor'
import { geolocationAtomDefinition } from '@exodus/geolocation/atoms'
ioc.registerMultiple([geolocationMonitorDefinition, geolocationAtomDefinition])
ioc.resolve()
const { geolocationAtom } = ioc.getByType('atom')
// get current geolocation
const {
// ...
ip,
countryName,
countryCode,
regionName,
regionCode,
isAllowed,
isProxy,
} = await geolocationAtom.get()
// subscribe to geolocation changes
geolocationAtom.observe((geolocation) => {})