Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Redux Toolkit instead of plain Redux #94

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions aiortc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
"dev": "cross-env DEBUG=\"${DEBUG:='*'}\" PYTHON_LOG_TO_STDOUT=true ROOM_ID=devel node ./lib/index.js"
},
"dependencies": {
"@reduxjs/toolkit": "^1.3.6",
"debug": "^4.1.1",
"fake-mediastreamtrack": "^1.1.3",
"mediasoup-client-aiortc": "github:versatica/mediasoup-client-aiortc#v3",
"protoo-client": "^4.0.3",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"repl": "^0.1.3",
"tsc-watch": "^4.1.0",
"typescript": "^3.6.5",
Expand Down
35 changes: 22 additions & 13 deletions aiortc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import * as repl from 'repl';
import {
applyMiddleware as applyReduxMiddleware,
createStore as createReduxStore
} from 'redux';
import thunk from 'redux-thunk';
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { Logger } from './Logger';
import { RoomClient } from './RoomClient';
import reducers from './redux/reducers';

const reduxMiddlewares = [ thunk ];
import room from './redux/reducers/room';
import me from './redux/reducers/me';
import producers from './redux/reducers/producers';
import dataProducers from './redux/reducers/dataProducers';
import peers from './redux/reducers/peers';
import consumers from './redux/reducers/consumers';
import dataConsumers from './redux/reducers/dataConsumers';

const logger = new Logger();

const store = createReduxStore(
reducers,
undefined,
applyReduxMiddleware(...reduxMiddlewares)
);
const store = configureStore({
reducer: {
room,
me,
producers,
dataProducers,
peers,
consumers,
dataConsumers
},
middleware : getDefaultMiddleware({
serializableCheck : false
})
});

RoomClient.init({ store });

Expand Down
21 changes: 0 additions & 21 deletions aiortc/src/redux/reducers/index.ts

This file was deleted.

51 changes: 25 additions & 26 deletions app/lib/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import UrlParse from 'url-parse';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import {
applyMiddleware as applyReduxMiddleware,
createStore as createReduxStore
} from 'redux';
import thunk from 'redux-thunk';
// import { createLogger as createReduxLogger } from 'redux-logger';
import randomString from 'random-string';
import * as faceapi from 'face-api.js';
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import Logger from './Logger';
import * as utils from './utils';
import randomName from './randomName';
Expand All @@ -19,31 +14,35 @@ import RoomClient from './RoomClient';
import RoomContext from './RoomContext';
import * as cookiesManager from './cookiesManager';
import * as stateActions from './redux/stateActions';
import reducers from './redux/reducers';
import room from './redux/reducers/room';
import me from './redux/reducers/me';
import producers from './redux/reducers/producers';
import dataProducers from './redux/reducers/dataProducers';
import peers from './redux/reducers/peers';
import consumers from './redux/reducers/consumers';
import dataConsumers from './redux/reducers/dataConsumers';
import notifications from './redux/reducers/notifications';
import Room from './components/Room';

const logger = new Logger();
const reduxMiddlewares = [ thunk ];

// if (process.env.NODE_ENV === 'development')
// {
// const reduxLogger = createReduxLogger(
// {
// duration : true,
// timestamp : false,
// level : 'log',
// logErrors : true
// });

// reduxMiddlewares.push(reduxLogger);
// }

let roomClient;
const store = createReduxStore(
reducers,
undefined,
applyReduxMiddleware(...reduxMiddlewares)
);

const store = configureStore({
reducer : {
room,
me,
producers,
dataProducers,
peers,
consumers,
dataConsumers,
notifications
},
middleware : getDefaultMiddleware({
serializableCheck : false
})
});

window.STORE = store;

Expand Down
23 changes: 0 additions & 23 deletions app/lib/redux/reducers/index.js

This file was deleted.

4 changes: 1 addition & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@babel/runtime": "^7.8.4",
"@reduxjs/toolkit": "^1.3.6",
"bowser": "^2.9.0",
"classnames": "^2.2.6",
"clipboard-copy": "^3.1.0",
Expand All @@ -33,9 +34,6 @@
"react-spinner": "^0.2.7",
"react-tooltip": "^3.11.1",
"react-transition-group": "^4.3.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"riek": "^1.1.0",
"url-parse": "^1.4.7"
},
Expand Down