This hook is used to fetch pre-match and live Conditions
of a specific game.
Hook represents a logic wrapper over standard Apollo's useQuery
hook. Explore Apollo's docs (opens in a new tab) to understand what data the hooks return.
⚠️
The Hook should be used if useGameMarkets
doesn't suit your needs. Here (opens in a new tab) is an example demonstrating usage, employing the useGameMarkets
hook.
Usage
import { useConditions } from '@azuro-org/data'
const { loading, error, conditions } = useConditions(props)
Props
{
gameId: string | bigint
isLive: boolean // if the flag is set to true, useConditions will retrieve live conditions.
livePollInterval?: number // live conditions can be created at any time, and here, you can specify how frequently to check for new live conditions **measured in miliseconds**
filter?: {
outcomeIds?: string[]
}
}
⚠️
gameId
property is not the same as id
. Each game fetched using useGames
hook contains the gameId:
import { useGame } from '@azuro-org/data'
const { loading, error, data } = useGames()
const gameId = data?.games[0]?.gameId
const { loading, error, data } = useConditions({ gameId })
Return Value
{
loading: boolean
error: Error | null
conditions: Array<{
id: string
conditionId: string
status
core: {
address: string
liquidityPool: {
address: string
}
}
outcomes: Array<{
outcomeId: string
odds: string
}>
}>
}