UNPKG

stream-chat-react-native-core

Version:

The official React Native and Expo components for Stream Chat, a service for building chat applications

29 lines (21 loc) 780 B
import { StateStore } from 'stream-chat'; import type { ChannelUnreadState as ChannelUnreadStateType } from '../types/types'; export type ChannelUnreadStateStoreType = { channelUnreadState?: ChannelUnreadStateType; }; const INITIAL_STATE: ChannelUnreadStateStoreType = { channelUnreadState: undefined, }; export class ChannelUnreadStateStore { public state: StateStore<ChannelUnreadStateStoreType>; constructor() { this.state = new StateStore<ChannelUnreadStateStoreType>(INITIAL_STATE); } set channelUnreadState(data: ChannelUnreadStateStoreType['channelUnreadState']) { this.state.next({ channelUnreadState: data }); } get channelUnreadState() { const { channelUnreadState } = this.state.getLatestValue(); return channelUnreadState; } }