Skip to main content
Logo
Explore APIsContact Us
  • Home
  1. Virtual Stadium
  2. Social Features

Social Features

Follow users, load followers and following lists, and search within the Central Hub community.

#Following Users

CentralHubFollowingManager manages follow and unfollow actions and emits follow events so your UI can react immediately.

kotlin
class FollowingViewModel : ViewModel(), KoinComponent {

    private val followingManager: CentralHubFollowingManager = get()

    val followEvents = followingManager.followEvents

    suspend fun followUser(userId: String) {
        followingManager.followUser(
            userId = userId,
            onSuccess = { /* User followed */ },
            onFailure = { error -> /* Handle error */ },
        )
    }

    suspend fun unfollowUser(userId: String) {
        followingManager.unfollowUser(
            userId = userId,
            onSuccess = { /* User unfollowed */ },
            onFailure = { error -> /* Handle error */ },
        )
    }
}

#Viewing Followers

CentralHubFollowersProvider loads followers and following lists with sorting and pagination support.

#Sort Options

  • FollowersSortType.Latest — newest followers first.
  • FollowersSortType.Earliest — oldest followers first.
kotlin
class FollowersViewModel : ViewModel(), KoinComponent {

    private val followersProvider: CentralHubFollowersProvider = get()

    val followersState = followersProvider.state

    suspend fun loadFollowers(userId: String) {
        followersProvider.loadData(
            userId = userId,
            sortType = FollowersSortType.Latest,
            pageLimit = 20,
        )
    }

    fun loadMore(
        followingType: FollowingType,
        sortType: FollowersSortType,
    ) {
        followersProvider.loadNextPage(
            followingType = followingType,
            sortType = sortType,
            pageLimit = 20,
        )
    }
}

#Searching for Users

CentralHubSearchProvider searches users across the community or within follower subsets.

#Search Types

  • SearchType.ALL — search all users.
  • SearchType.FOLLOWING — search only followed users.
  • SearchType.FOLLOWERS — search only followers.
kotlin
class SearchViewModel : ViewModel(), KoinComponent {

    private val searchProvider: CentralHubSearchProvider = get()

    val searchState = searchProvider.state

    suspend fun search(
        query: String,
        searchType: SearchType = SearchType.ALL,
    ) {
        if (query.isNotBlank()) {
            searchProvider.search(
                query = query,
                searchType = searchType,
                pageLimit = 20,
            )
        }
    }

    suspend fun loadMoreResults(
        query: String,
        searchType: SearchType,
    ) {
        searchProvider.loadNextSearchPage(
            query = query,
            searchType = searchType,
            pageLimit = 20,
        )
    }

    fun clearSearch() {
        searchProvider.clear()
    }

    override fun onCleared() {
        super.onCleared()
        searchProvider.destroy()
    }
}

#Data Models

#FollowersState

kotlin
data class FollowersState(
    val followers: List<Follower>,
    val following: List<Follower>,
    val followersCount: Int,
    val followingCount: Int,
    val followersNextPage: String?,
    val followingNextPage: String?,
    val loadingStatus: LoadingStatus,
    val nextPageLoadingStatus: LoadingStatus,
    val followActionLoadingStatus: LoadingStatus,
)

#CentralHubSearchState

kotlin
data class CentralHubSearchState(
    val searchResults: List<Follower>,
    val loadingStatus: LoadingStatus,
    val nextPageLoadingStatus: LoadingStatus,
    val followActionLoadingStatus: LoadingStatus,
    val allDataLoaded: Boolean,
)

#Related Topics

  • User Profiles - View user profile details.
  • Notifications - Show new follower activity.
Last updated 27 days ago
Is this site helpful?
Virtual Stadium, Moderation, Engagement Tools, BET
Copying BetsLeaderboards
On this page
  • Following Users
  • Viewing Followers
  • Sort Options
  • Searching for Users
  • Search Types
  • Data Models
  • FollowersState
  • CentralHubSearchState
  • Related Topics