Channels
Channels are virtual environments where users can communicate with each other and exchange messages. Your application creates channels with a unique id, a name, and a description. You can also save additional properties as custom fields in the channel. These additional properties can be anything you like, such as an image icon, such as a display color, star ratings, moderator names, and more.
State Shape
The data about an individual channel is stored as a slice in a normalized pool of Channels. The following example shows the shape of a list of Channels in the store:
{
"byId": {
"channel_ac4e67b98b34b44c4a39466e93e": {
"id": "channel_ac4e67b98b34b44c4a39466e93e",
"name": "Introductions",
"description": "This channel is for company wide chatter",
"updated": "2019-11-08T21:42:30.661344Z",
"eTag": "AYr89/Sb5KDi4gE"
},
"channel_a652eb6cc340334ff0b244c4a39": {
"id": "channel_a652eb6cc340334ff0b244c4a39",
"name": "London Office",
"description": "London Office 🇬🇧",
"updated": "2019-11-08T21:42:30.965912Z",
"eTag": " AfD93cn945yNTA"
show all 18 linesReducers
The PubNub Redux framework provides reducers your app can implement that respond to various actions that update the store. To track the state of a set of objects in the store, combine the reducers you want into the rootReducer
for your app.
createChannelDataReducer
createChannelDataReducer
instantiates a reducer in the store that responds to actions dispatched to update the state of channels in the store.
createChannelDataReducer();
createChannelsListReducer
createChannelsListReducer
instantiates a reducer in the store that responds to actions that put a list of channel IDs (as string
values) into the store.
createChannelsListReducer();
Listeners
The PubNub Redux framework includes listeners that monitor PubNub events from the server and dispatch corresponding actions. All listeners are automatically invoked if your app registers the combined PubNub listener. You can register only specific listeners, or implement your own combine listeners function.
createChannelDataListener
createChannelDataListener
registers a listener in the store that monitors channel-related events, such as ChannelDataSet and ChannelDataRemoved, and dispatches corresponding actions to update the store.
A sample implementation of a single listener:
pubnub.addListener(createChannelDataListener(store.dispatch));