This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, of } from 'rxjs'; | |
import { catchError, mergeMap, switchMap } from 'rxjs/operators'; | |
const exampleEpic = action$ => | |
action$.pipe( | |
ofType(types.ACTION_REQUEST), | |
switchMap(({ payload }) => | |
from(api.get(payload.data)).pipe( | |
mergeMap(response => | |
of( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, of, concat } from 'rxjs'; | |
import { catchError, mergeMap, switchMap } from 'rxjs/operators'; | |
const exampleEpic = action$ => | |
action$.pipe( | |
ofType(types.ACTION_REQUEST), | |
switchMap(({ payload }) => | |
concat( | |
of(loadingList()), // Here we define the loading action for our list | |
from(api.get(payload.data)).pipe( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, of, concat } from 'rxjs'; | |
import { catchError, mergeMap, switchMap } from 'rxjs/operators'; | |
import { startSubmit, stopSubmit } from 'redux-form'; | |
const exampleEpic = action$ => | |
action$.pipe( | |
ofType(types.ACTION_REQUEST), | |
switchMap(({ payload, meta }) => // yes, meta! | |
concat( | |
of(startSubmit(meta.formName)), // Here we define that this specific form is submitting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionsObservable, StateObservable } from 'redux-observable'; | |
... | |
it('expects to work perfectly', async () => { | |
const mockedResponse = {}; | |
const action$ = ActionsObservable.of(action.actionRequest()); | |
const expected = [ | |
addDataAction(mockedResponse), // action 1 | |
pushInfoSnackbar('created successfully') // action 2 | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionsObservable, StateObservable } from 'redux-observable'; | |
... | |
it('expects to NOT work perfectly', async () => { | |
const action$ = ActionsObservable.of(action.actionRequest()); | |
const expected = [ | |
of(pushWarningSnackbar('Failed to create shareable folder')); // failed action | |
]; | |
mockAxios.onGet().reply(400, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, of, concat } from 'rxjs'; | |
import { catchError, mergeMap, switchMap, takeUntil } from 'rxjs/operators'; | |
import { startSubmit, stopSubmit } from 'redux-form'; | |
const exampleEpic = action$ => | |
action$.pipe( | |
ofType(types.ACTION_REQUEST), | |
switchMap(({ payload, meta }) => // yes, meta! | |
concat( | |
of(startSubmit(meta.formName)), // Here we define that this specific form is submitting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Animated } from 'react-native'; | |
const PanExample = () => { | |
const panResponder = PanResponder.create({ | |
onStartShouldSetPanResponder: () => true, // we are enabling pan responder on start with this. So now we can listen tap and move | |
onPanResponderMove: (evt, gestureState) => { | |
// here we are listening every move | |
// evt and gestureState simply returns the x,y of the movement position | |
console.log('yes we are moving', gestureState.dy, gestureState.dx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
SET_USER_TOKEN, | |
SetUserTokenAction, | |
} from './types'; | |
import { simpleAction } from '../utils'; | |
export const setUserToken = (token: string): SetUserTokenAction => | |
simpleAction(SET_USER_TOKEN, token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const SET_USER_TOKEN = 'SET_USER_TOKEN'; | |
export interface SetUserTokenAction { | |
type: typeof SET_USER_TOKEN; | |
payload: string; | |
} | |
export type UserActionTypes = | |
| SetUserTokenAction | |
| ActionB // other action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SET_USER, SET_USER_TOKEN, UNSET_USER, UserActionTypes } from './types'; | |
import { User } from './types'; | |
const initialState: User = { | |
id: null, | |
name: '', | |
email: '', | |
}; | |
function userInfo(state = initialState, action: UserActionTypes): User { |