Redux -> simple fixes

feature/0_redux_slices
TBS093A 2021-02-17 14:50:33 +01:00
parent 74de7cf0c8
commit 9f90fa0ba2
3 changed files with 29 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import { GeneralAddress } from './abstractAddress'
const APIAddress = 'http://' + GeneralAddress
let defaultBody = ''
let defaultBody = {}
const _getList = async (endpoint, token) => {
return await responseAbstract(

View File

@ -45,14 +45,26 @@ const __make_address = async (endpoint) => {
return GeneralAddress + endpoint
}
/**
* @param body:
* param token: token
* param endpoint:
* examples:
* 'image' - connect to single image ws renderer
* 'set' - connect to single set ws renderer
* 'all' - connect to all ws renderer
*
* 'vector/image' - connect to vector single image ws renderer
* 'vector/set' - connerct to vector single set ws renderer
*/
const fetchConnect = createAsyncThunk(
'render/async/fetchConnect',
async (
endpoint,
body,
thunkAPI
) => {
let uuid = __uuidv4()
let address = __make_address(endpoint)
let address = __make_address(body.endpoint)
return {
web_socket: new WebSocket(address + uuid),
address: address,
@ -61,21 +73,31 @@ const fetchConnect = createAsyncThunk(
}
)
/**
* @param body:
* param token: token
* param message: message string
*/
const fetchSaveMessage = createAsyncThunk(
'render/async/fetchSaveMessage',
async (
message,
body,
thunkAPI
) => {
return {
message: message
message: body.message
}
}
)
/**
* @param body:
* param token: token
*/
const fetchDisconnect = createAsyncThunk(
'render/async/fetchDisconnect',
async (
token,
thunkAPI
) => {
return {

View File

@ -37,6 +37,6 @@ const renderWebsocketSlice = createSlice(
}
)
export const userAuthReducer = userAuthSlice.reducer
export const renderWebsocketReducer = renderWebsocketSlice.reducer
export const userAuthSelector = state => state.userAuthReducer
export const renderWebsocketSelector = state => state.renderWebsocketReducer