score:5
Accepted answer
function createRtcMiddleware() {
return (store) => {
let rtcPeerConnection = null;
return (next) => action => {
switch(action.type) {
case "RTC_CONNECTION_CREATE": {
const {rtcConfig} = action;
rtcPeerConnection = new RTCPeerConnection(rtcConfig);
rtcPeerConnection.somecallback = () => {
// maybe dispatch a Redux action in response to
// a received message
};
// Do not pass the action down the pipeline, since only
// this middleware cares about it
return;
}
case "RTC_CONNECTION_SET_DESCRIPTION": {
if(rtcPeerConnection) {
rtcPeerConnection.setDescription(action.description);
}
return;
}
}
// If we don't care about it, pass it down the pipeline
return next(action);
}
}
}
Source: stackoverflow.com
Related Query
- Where is the best place to store an RTCPeerConnection object in a React/Redux app?
- What is the best way to access redux store outside a react component?
- Where to store WebRTC streams when building React app with redux
- Redux: where to place interaction with the DOM, that is triggered by an action but changes outside of the React app
- How to best store a complex object of MQTT messages in a React App State?
- Structuring the store of a localized react / redux app
- React - Where is the best place to fetch data?
- In a react app, where is the best place to kick off the initial API service call for data load?
- Having difficulty iterating through an Object of Arrays and generating dynamic React elements in JSX from within the Redux Store
- Which is the best way to store a list of data in localStorage and display them when searched using a React app
- React js, What is the best way to store redux state into local state?
- using redux and redux-persist in react app: after submitting the form, store create a new and empty object
- What is the proper way of updating this Redux store state in React app
- What is the best way to store data with React Redux but by condition?
- Unable to read data from Redux store in the React app
- Implement a feature in my React app where the users can add my products to their Shopify store
- Adding new array object to a nested array in react redux reducer and array in store updates but not the react component
- React + Redux - What's the best way to handle CRUD in a form component?
- How to show a loading indicator in React Redux app while fetching the data?
- What is the necessity of "export default connect" when you are connecting your react component to redux store
- How do I use local state along with redux store state in the same react component?
- Storing "global" object outside of Redux store in React/Redux app
- Developing a Redux store as a seperate NPM module for a React App
- Best way to store file objects in React Redux store (files upload from DropZone?)
- How to access the Redux store outside of a component in React
- What is the best way to secure Firebase API keys in a react app so it is not accessible publicly?
- What is the best way to implement undo state change (undo store/history implementation) in React Redux
- How can I cache data that I already requested and access it from the store using React and Redux Toolkit
- Where to have the socket object in your redux app?
- Where to store user's credentials in React Native Mobile App
More Query from same tag
- Autocomplete Search Via Another Paramter
- Filtering function running one step too late
- Use Bootstrap 4 with React
- ReactJs render doesn't update properly on data change
- How can I show the latest data by date using sort in react typescript
- How to load a specific photo with dynamic URL with react.js
- Is it safe to modify a react state directly, if you don't need a rerender?
- ReactJS Change Sibling State via Parent
- How to specify in which pages stripejs script can be loaded?
- Submit form in ReactJS using BUTTON element
- Unable to pause React audio
- How do I get scss working with a react project?
- React Hooks State is not updated the first time
- How to load proper value in Autocomplete MUI from DB
- How to resize table component in react semantic ui?
- Header component doesn't get updated after route change
- Get Flatpickr time data in Unix format
- React unexpected number rendered
- React rendering is messing up my ref binding with Masonry
- Only CSS and HTML tab component
- Trouble getting Jest and enzyme to render a div test from my App.js
- React: Cannot call functions from another file
- Why wouldn't React Router work with <Switch>?
- Radar Chart Not working in React Highcharts
- Adding Header & Footer for all screens in JSPDF
- group results of javascript map
- How to prevent style tags of unused React components
- Specifying array of functions with unknown arguments throws a typeerror
- how to render header, footer, menu, only once and only for private routes with react js?
- Why when I write array.map, foreach, or a simple for, it runs async in Electron + Javascript?