How to use the redux-act.createAction function in redux-act

To help you get started, we’ve selected a few redux-act examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danilobjr / timer / src / redux / modules / toast.ts View on Github external
import { createActionDescription } from 'src/redux/utils';
import { v1 as uuid } from 'uuid';
import { delay } from 'redux-saga';
import { ToastMessage } from 'src/redux/models';
import { Toast } from 'models';

// ACTIONS

const actionDescription = createActionDescription('toast');

export const actions = {
  showMessage: createAction(actionDescription('SHOW_MESSAGE')),

  // INTERNAL
  addToast: createAction(actionDescription('SHOW_TOAST')),
  hideToast: createAction(actionDescription('HIDE_TOAST')),
  removeToast: createAction(actionDescription('REMOVE_TOAST')),
  showToast: createAction(actionDescription('SHOW_TOAST')),
};

// STATE

const initialState = {
  toast: null as Toast,
};

export type ToastState = typeof initialState;

// REDUCER

const toast = createReducer({}, initialState.toast)
  .on(actions.addToast, (_, toast) => toast)
github Imater / 4redux / src / routes / CalendarPage / modules / holidays.js View on Github external
import { createReducer, createAction } from 'redux-act'
import { loop, Effects } from 'redux-loop'
import client from '../../../helpers/apiClient'

export const fetch = createAction('mg/holidays/getHolidays')
export const fetchSuccess = createAction('mg/holidays/getHolidaysSuccess')
export const fetchFailure = createAction('mg/holidays/getHolidaysFailure')

const initialState = {
  isLoaded: false,
  isLoading: false,
  data: {}
}

const request = (country, year) => () =>
  client.get(`https://holidayapi.com/v1/holidays?key=f988097d-8481-420d-8f86-6b29abec97c4&country=${country}&year=${year}`)
    .then(fetchSuccess)
    .catch(fetchFailure)

const handleFetch = (state, payload) => {
  const { country, year } = payload

  return loop({
github Imater / 4redux / src / routes / CalendarPage / modules / holidays.js View on Github external
import { createReducer, createAction } from 'redux-act'
import { loop, Effects } from 'redux-loop'
import client from '../../../helpers/apiClient'

export const fetch = createAction('mg/holidays/getHolidays')
export const fetchSuccess = createAction('mg/holidays/getHolidaysSuccess')
export const fetchFailure = createAction('mg/holidays/getHolidaysFailure')

const initialState = {
  isLoaded: false,
  isLoading: false,
  data: {}
}

const request = (country, year) => () =>
  client.get(`https://holidayapi.com/v1/holidays?key=f988097d-8481-420d-8f86-6b29abec97c4&country=${country}&year=${year}`)
    .then(fetchSuccess)
    .catch(fetchFailure)

const handleFetch = (state, payload) => {
  const { country, year } = payload
github gluon-project / gluon-rxp / src / Reducers / ContactsReducer.ts View on Github external
reducer.on(setGroupClaimsBy, (state: ContactsState, payload?: any) => {
  return {
    ...state,
    groupClaimsBy: payload,
  }
})

export const setRoomForSharing = createAction('Set Room For Sharing clam')
reducer.on(setRoomForSharing, (state: ContactsState, payload?: string) => {
  return {
    ...state,
    roomForSharing: payload,
  }
})

export const addContact = createAction('Add contact')
reducer.on(addContact, (state: ContactsState, payload?: User) => {
  let list = [...state.list]
  remove(list, (item: User) => {
    return item.address === payload.address
  })
  return {
    ...state,
    list: [ ...list, payload ],
  }
})

export const setForEditing = createAction('Set contact for editing')
reducer.on(setForEditing, (state: ContactsState, payload?: User) => {
  return {
    ...state,
    editing: payload,
github tsirlucas / soundplace / src / core / user / user.actions.ts View on Github external
import {createAction} from 'redux-act';

import {User} from 'models';

export const actions = {
  subscribeUser: createAction('user/SUBSCRIBE_USER'),
  unsubscribeUser: createAction('user/UNSUBSCRIBE_USER'),
  import: createAction('user/IMPORT'),
  cancelImport: createAction('user/CANCEL_IMPORT'),
  setUser: createAction('user/SET_USER'),
  setToken: createAction('user/SET_TOKEN'),
};

type ActionsType = typeof actions;
export type Actions = {[P in keyof ActionsType]: ReturnType};
github alephdata / aleph / ui / src / actions / sessionActions.js View on Github external
import { createAction } from 'redux-act';
import { endpoint } from 'src/app/api';

export const loginWithToken = createAction('LOGIN');
export const logout = createAction('LOGOUT');

export const loginWithPassword = (email, password) => async (dispatch) => {
  const response = await endpoint.post('/sessions/login', { email, password });
  dispatch(loginWithToken(response.data.token));
};
github RodionChachura / simple-blog-front / src / actions / generic.js View on Github external
import { createAction } from 'redux-act'

export const startApp = createAction()
export const enterPage = createAction()
export const exitPage = createAction()
export const moveMouse = createAction()
export const changePageSize = createAction()
export const tick = createAction()
export const toggleSnackbar = createAction()
github go-faast / faast-web / src / app / actions / redux.js View on Github external
import { createAction } from 'redux-act'

export const resetAll = createAction('RESET_ALL')

export const setMock = createAction('SET_MOCK')

export const toggleOrderModal = createAction('TOGGLE_ORDER_MODAL')

export const showOrderModal = createAction('SHOW_ORDER_MODAL')

export const hideOrderModal = createAction('HIDE_ORDER_MODAL')

export const setSettings = createAction('SET_SETTINGS')

redux-act

An opinionated lib to create actions and reducers for Redux

Apache-2.0
Latest version published 5 years ago

Package Health Score

51 / 100
Full package analysis