Skip to main content
Logo
Explore APIsContact Us
  • Home
  1. Virtual Stadium
  2. Bet Sharing

Bet Sharing

Share betslips with the Central Hub community and load shared bets from the community feed.

#Creating Bet Shares

Use CentralHubBetShareProvider when you want to publish a betslip with an optional comment and optional stake visibility.

kotlin
class CentralHubViewModel : ViewModel(), KoinComponent {

    private val betShareProvider: CentralHubBetShareProvider = get()

    suspend fun shareBet(
        betPayload: BetPayload,
        comment: String?,
        showStake: Boolean,
    ) {
        betShareProvider.createBetShare(
            betPayload = betPayload,
            comment = comment,
            showStake = showStake,
            onSuccess = { /* Handle success */ },
            onFailure = { error -> /* Handle error */ },
        )
    }
}

#Browsing Shared Bets

Use CentralHubBetsProvider to load and paginate shared betslips.

The provider supports:

  • filtering,
  • sorting, and
  • incremental loading for larger feeds.

#Filter Options

  • BetShareFilterType.ALL — show every shared bet.
  • BetShareFilterType.FOLLOWERS_BETS — show only bets shared by followed users.
  • BetShareFilterType.MY_SHARED_BETS — show only the signed-in user's shared bets.
  • BetShareFilterType.MY_CONVERSATIONS — show bets where the user has joined the conversation.
  • BetShareFilterType.WINNING_BETS — show only winning bet shares.

#Sort Options

  • BetShareSortType.CREATED — sort by creation time.
  • BetShareSortType.COMMENT_COUNT — sort by most commented.
  • BetShareSortType.COPY_COUNT — sort by most copied.
kotlin
class BetsViewModel : ViewModel(), KoinComponent {

    private val betsProvider: CentralHubBetsProvider = get()

    val betsState = betsProvider.state

    fun loadBets(
        filterType: BetShareFilterType,
        sortType: BetShareSortType,
    ) {
        betsProvider.loadBetShares(filterType, sortType)
    }

    fun loadMore(
        filterType: BetShareFilterType,
        sortType: BetShareSortType,
    ) {
        betsProvider.loadMoreBetShares(filterType, sortType)
    }
}
kotlin
@Composable
fun BetsFeed(viewModel: BetsViewModel = viewModel()) {
    val state by viewModel.betsState.collectAsStateWithLifecycle()

    LazyColumn {
        items(state.sharedBets) { betShare ->
            BetShareCard(betShare)
        }

        if (!state.allDataLoaded) {
            item {
                LoadMoreButton {
                    viewModel.loadMore(
                        BetShareFilterType.ALL,
                        BetShareSortType.CREATED,
                    )
                }
            }
        }
    }
}

#Data Models

#BetShare

kotlin
data class BetShare(
    val id: String,
    val messageId: String?,
    val channelId: String?,
    val content: String,
    val numOfUnreadComments: Int,
    val numOfAllComments: Int,
    val userFollowersCount: Int?,
    val betPayload: BetPayload,
    val isMy: Boolean,
    val betShareCopyCount: Int,
    val user: User,
    val createdAt: Long,
    val showStake: Boolean,
    val comments: List<MessageReply>,
    val reactions: List<Reaction>,
)

#CentralHubBetsState

kotlin
data class CentralHubBetsState(
    val sharedBets: List<BetShare>,
    val loadingState: LoadingStatus,
    val previousPageLoadingStatus: LoadingStatus,
    val allDataLoaded: Boolean,
)

#Related Topics

  • Copying Bets - Copy shared bets to your bet slip.
  • Comments & Reactions - Engage with shared bets.
  • Notifications - Get notified about new bet shares.
Last updated 27 days ago
Is this site helpful?
Virtual Stadium, Moderation, Engagement Tools, BET
User ProfilesNotifications
On this page
  • Creating Bet Shares
  • Browsing Shared Bets
  • Filter Options
  • Sort Options
  • Data Models
  • BetShare
  • CentralHubBetsState
  • Related Topics