I hereby claim:
- I am acr13 on github.
- I am acr13 (https://keybase.io/acr13) on keybase.
- I have a public key ASD76yNBNjSImYKAyGXhDKGODzLMzK-ncJW29QNw27_4PQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| import { delay } from 'redux-saga'; | |
| import { call, put, select, take } from 'redux-saga/effects'; | |
| import { getFlashQueue } from './getters'; | |
| import { ADD_FLASH_MESSAGE, SHOW_FLASH, CLEAR_FLASH } from './actions'; | |
| const FIVE_SECONDS = 5000; | |
| export function* showFlashMessage() { | |
| yield put({ type: SHOW_FLASH }); |
| import { race, cancel, take, fork, all, put, select } from 'redux-saga/effects'; | |
| export function* fetchDataForPage() { | |
| const userId = yield select(getUserId); | |
| try { | |
| if (!userId) { | |
| throw new Error('No user - aborting'); | |
| } |
| // Watcher | |
| export function* onPageInit() { | |
| yield takeLatest(ON_PAGE_MOUNT, fetchDataForPage); | |
| } | |
| // Saga | |
| export function* fetchDataForPage() { | |
| // Get any dependencies (from your store, or locally, etc) | |
| const userId = yield select(getUserId); | |
| const dependency = 42; |
| import { call, put, select } from 'redux-saga/effects'; | |
| import { API_BUTTON_CLICK_SUCCESS, API_BUTTON_CLICK_ERROR, } from './actions/consts'; | |
| import { getUserAccessToken } from './selectors'; | |
| import { getDataFromAPI } from './api'; | |
| import { apiSideEffect } from './sagas'; | |
| it('apiSideEffect - dispatches API_BUTTON_CLICK_ERROR if we aren\'t authenticated', () => { | |
| const generator = apiSideEffect(); | |
| const fakeAccessToken = ''; // or false, null, etc |
| import { call, put, select, takeEvery } from 'redux-saga/effects'; | |
| import { | |
| API_BUTTON_CLICK, | |
| API_BUTTON_CLICK_SUCCESS, | |
| API_BUTTON_CLICK_ERROR, | |
| } from './actions/consts'; | |
| import { getDataFromAPI } from './api'; | |
| import { getUserAccessToken } from './selectors'; |
| import { call, put } from 'redux-saga/effects'; | |
| import { API_BUTTON_CLICK_SUCCESS, } from './actions/consts'; | |
| import { getDataFromAPI } from './api'; | |
| it('apiSideEffect - fetches data from API and dispatches a success action', () => { | |
| const generator = apiSideEffect(); | |
| expect(generator.next().value) | |
| .toEqual(call(getDataFromAPI)); |
| import { call, put, takeEvery } from 'redux-saga/effects'; | |
| import { | |
| API_BUTTON_CLICK, | |
| API_BUTTON_CLICK_SUCCESS, | |
| API_BUTTON_CLICK_ERROR, | |
| } from './actions/consts'; | |
| import { getDataFromAPI } from './api'; | |
| export function* apiSideEffect(action) { |
| const range = (sh, sm = 0, eh = 0, em = 0) => ({ | |
| start: (sh * 100) + sm, | |
| end: (eh * 100) + em | |
| }); | |
| // const A = [ range(9, 0, 10, 0) ]; | |
| // const B = [ range(9, 0, 9, 30) ]; | |
| // const A = [ range(9, 0, 10, 0) ]; | |
| // const B = [ range(9, 15, 9, 30) ]; |
| const R = require('ramda'); | |
| const NUM_CARDS_IN_DECK = 52; | |
| const NUM_CARDS_PER_PLAYER = 2; | |
| const NUM_PLAYERS = 2; | |
| const possibleValues = [ | |
| '2', '3', '4', '5', '6', '7', '8', '9', | |
| '10', 'J', 'Q', 'K', 'A' | |
| ]; |