- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
import { combineEpics, ofType } from 'redux-observable'
import { map, switchMap, catchError, filter, mergeAll } from 'rxjs/operators'
import { of, from } from 'rxjs'
import * as R from 'ramda'
import * as TICKETS_ACTION_TYPES from './tickets.types'
import * as TicketsActions from './tickets.actions'
import * as TicketsSelectors from './tickets.selectors'
import { /* TICKET_TYPES,*/ TICKET_STEPS } from './constants'
import mockAPI from 'services/mockAPI'
export const getTicketsEpic = (action$, state$) =>
from(
R.map(
(step) =>
action$.pipe(
filter(
R.either(
R.both(R.propEq('type', TICKETS_ACTION_TYPES.GET_TICKETS_BY_STEP), R.pathEq(['payload', 'step'], step)),
R.propEq('type', TICKETS_ACTION_TYPES.GET_ALL_TICKETS)
)
),
switchMap((action) => {
if (
action.type !== TICKETS_ACTION_TYPES.GET_ALL_TICKETS &&
TicketsSelectors.ticketsAllDirtySelector(state$.value)
) {
return of(TicketsActions.getAllTickets())
} else if (!TicketsSelectors.ticketsByStepDirtySelector(step, state$.value)) {
return of(TicketsActions.getTicketsByStepSuccess(step, null, true))
}
return from(
// Mocks tickets API
// TODO: Replace by real request
mockAPI.getTicketsByStep(step)
).pipe(
map((data) => TicketsActions.getTicketsByStepSuccess(step, data)),
catchError((err) => of(TicketsActions.getTicketsByStepError(step, err)))
)
})
),
R.values(TICKET_STEPS)
)
).pipe(mergeAll())
Редукс нам уже не интересен, нам с поподвыподвертами подавай, чтоб тупо болванку показать.
NickPepper 25.07.2020 16:15 # 0
guest8 25.07.2020 16:18 # −999
NickPepper 25.07.2020 16:19 # 0
guest8 25.07.2020 16:20 # −999
NickPepper 25.07.2020 16:24 # 0
NickPepper 25.07.2020 16:39 # 0
Fike 25.07.2020 22:21 # 0
NickPepper 26.07.2020 01:29 # 0
Fike 26.07.2020 01:43 # 0
NickPepper 26.07.2020 01:45 # 0
Fike 26.07.2020 02:11 # 0
NickPepper 26.07.2020 08:40 # +1
Fike 26.07.2020 10:34 # 0
bootcamp_dropout 26.07.2020 12:16 # 0
Но тут этого нет, поэтому вероятно что просто выебуются
NickPepper 26.07.2020 15:20 # 0
bootcamp_dropout 26.07.2020 17:43 # 0
NickPepper 26.07.2020 15:21 # 0
MAKAKA 27.07.2020 02:07 # 0
ненавижу код с лесенками
NickPepper 27.07.2020 10:36 # 0