The RealtimeKit Stores API allows you to create multiple key-value pair realtime stores. Users can subscribe to changes in a store and receive real-time updates. Data is stored until a session is active.
This page is not available for the Flutter platform.
Web Mobile
React Web Components Angular
You can create a realtime store (changes are synced with other users):
Param Type Description Required namestring Name of the store true
To create a store:
const stores = useRealtimeKitSelector ( ( m ) => m . stores ) ;
const store = stores . create ( 'myStore' ) ;
const store = meeting . stores . create ( 'myStore' ) ;
const store = meeting . stores . create ( 'myStore' ) ;
val meeting = RealtimeKitMeetingBuilder. build (activity)
val store = meeting.stores. create ( "myStore" )
let meeting = RealtimeKitiOSClientBuilder () . build ()
let store = meeting. stores . create ( name : "myStore" )
This feature is not currently supported in the Flutter SDK
You can add, update or delete entries in a store:
Param Type Description Required keystring Unique identifier used to store/update a value in the store Yes valueStoreValue Value that can be stored against a key Yes
type StoreValue = string | number | object | array ;
const stores = useRealtimeKitSelector ( ( m ) => m . stores . stores ) ;
const store = stores . get ( "myStore" ) ;
await store . set ( "user" , { name : "John Doe" } ) ;
await store . update ( "user" , { age : 34 } ) ; // { name: 'John Doe', age: 34 }
await store . delete ( "user" ) ;
type StoreValue = string | number | object | array ;
const { stores } = meeting . stores ;
const store = stores . get ( "myStore" ) ;
await store . set ( "user" , { name : "John Doe" } ) ;
await store . update ( "user" , { age : 34 } ) ; // { name: 'John Doe', age: 34 }
await store . delete ( "user" ) ;
type StoreValue = string | number | object | array ;
const { stores } = meeting . stores ;
const store = stores . get ( "myStore" ) ;
await store . set ( "user" , { name : "John Doe" } ) ;
await store . update ( "user" , { age : 34 } ) ; // { name: 'John Doe', age: 34 }
await store . delete ( "user" ) ;
val store = meeting.stores. get ( "myStore" )
store. set ( "user" , mapOf ( "name" to "John Doe" ))
let store = meeting. stores . get ( name : "myStore" )
store. set ( "user" , [ "name" : "John Doe" ] )
Note
The set method overwrites the existing value, while the update method updates the existing value.
For example, if the stored value is ['a', 'b'] and you call update with ['c'], the final value will be ['a', 'b', 'c'].
You can attach event listeners on a store's key, which fire when the value changes.
const stores = useRealtimeKitSelector ( ( m ) => m . stores . stores ) ;
const store = stores . get ( 'myStore' ) ;
store . subscribe ( 'key' , ( data ) => {
// subscribe to all keys of a store
store . subscribe ( ' \* ' , ( data ) => {
store . unsubscribe ( 'key' ) ;
const { stores } = meeting . stores ;
const store = stores . get ( 'myStore' ) ;
store . subscribe ( 'key' , ( data ) => {
// subscribe to all keys of a store
store . subscribe ( ' \* ' , ( data ) => {
store . unsubscribe ( 'key' ) ;
const { stores } = meeting . stores ;
const store = stores . get ( 'myStore' ) ;
store . subscribe ( 'key' , ( data ) => {
// subscribe to all keys of a store
store . subscribe ( ' \* ' , ( data ) => {
store . unsubscribe ( 'key' ) ;
val store = meeting.stores. create ( "myStore" )
val keyChangeCallback = { key: String , value : Any ? ->
store. subscribe ( "key" , keyChangeCallback)
store. subscribe (RtkStore.WILDCARD_KEY) { key, value ->
store. unsubscribe ( "key" , keyChangeCallback)
let store = meeting. stores . create ( name : "myStore" )
let keyChangeCallback: (( String , ( Any ? )) -> Void ) = { key, value in
store. subscribe ( key : "key" , onChange : keyChangeCallback )
store. subscribe ( key : RtkStore.Companion () . WILDCARD_KEY ) { key, value in
store. unsubscribe ( key : "key" , onChange : keyChangeCallback )
You can fetch the data stored in the store:
const stores = useRealtimeKitSelector ( ( m ) => m . stores . stores ) ;
const store = stores . get ( 'myStore' ) ;
// fetch value for a specific key
const data = store . get ( 'key' ) ;
// fetch all the data in the store
const data = store . getAll () ;
const { stores } = meeting . stores ;
const store = stores . get ( 'myStore' ) ;
// fetch value for a specific key
const data = store . get ( 'key' ) ;
// fetch all the data in the store
const data = store . getAll () ;
const { stores } = meeting . stores ;
const store = stores . get ( 'myStore' ) ;
// fetch value for a specific key
const data = store . get ( 'key' ) ;
// fetch all the data in the store
const data = store . getAll () ;
val store = meeting.stores. create ( "myStore" )
// fetch value for a specific key
val data = store. get ( "key" )
// fetch all the data in the store
val data = store. getAll ()
let store = meeting. stores . create ( name : "myStore" )
// fetch value for a specific key
// fetch all the data in the store