How to use the redux-duck.createDuck function in redux-duck

To help you get started, we’ve selected a few redux-duck 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 ailabstw / pttai.js / src / reducers / AddFriendModal.js View on Github external
import Immutable from 'immutable'
import { createDuck } from 'redux-duck'

import * as utils from './utils'
import { myDuck as appDuck } from './App'

export const myClass = 'ADD_FRIEND_MODAL'

export const myDuck = createDuck(myClass, 'Add_Friend_Modal')

const INIT = myDuck.defineType('INIT')
const ADD_CHILD = myDuck.defineType('ADD_CHILD')
const SET_ROOT = myDuck.defineType('SET_ROOT')
const REMOVE_CHILDS = myDuck.defineType('REMOVE_CHILDS')
const REMOVE = myDuck.defineType('REMOVE')
const SET_DATA = myDuck.defineType('SET_DATA')

// init
export const init = (myId, query) => {
  return (dispatch, getState) => {
    dispatch(utils.init({ myId, myClass, myDuck, ...query }))
    dispatch(utils.setRoot(myId, myClass, appDuck))
  }
}
github ailabstw / pttai.js / src / reducers / EditArticleModal.js View on Github external
import Immutable from 'immutable'
import { createDuck } from 'redux-duck'

import * as utils from './utils'
import { myDuck as appDuck } from './App'

export const myClass = 'EDIT_ARTICLE_MODAL'

export const myDuck = createDuck(myClass, 'Edit_Article_Modal')

const INIT = myDuck.defineType('INIT')
const ADD_CHILD = myDuck.defineType('ADD_CHILD')
const SET_ROOT = myDuck.defineType('SET_ROOT')
const REMOVE_CHILDS = myDuck.defineType('REMOVE_CHILDS')
const REMOVE = myDuck.defineType('REMOVE')
const SET_DATA = myDuck.defineType('SET_DATA')

// init
export const init = (myId, query) => {
  return (dispatch, getState) => {
    dispatch(utils.init({ myId, myClass, myDuck, ...query }))
    dispatch(utils.setRoot(myId, myClass, appDuck))
  }
}
github ailabstw / pttai.js / src / reducers / AddDeviceModal.js View on Github external
import Immutable from 'immutable'
import { createDuck } from 'redux-duck'

import * as utils from './utils'
import { myDuck as appDuck } from './App'

export const myClass = 'ADD_DEVICE_MODAL'

export const myDuck = createDuck(myClass, 'Add_Device_Modal')

const INIT = myDuck.defineType('INIT')
const ADD_CHILD = myDuck.defineType('ADD_CHILD')
const SET_ROOT = myDuck.defineType('SET_ROOT')
const REMOVE_CHILDS = myDuck.defineType('REMOVE_CHILDS')
const REMOVE = myDuck.defineType('REMOVE')
const SET_DATA = myDuck.defineType('SET_DATA')

// init
export const init = (myId, query) => {
  return (dispatch, getState) => {
    dispatch(utils.init({ myId, myClass, myDuck, ...query }))
    dispatch(utils.setRoot(myId, myClass, appDuck))
  }
}
github ailabstw / pttai.js / src / reducers / EditNameModal.js View on Github external
import Immutable        from 'immutable'
import { createDuck }   from 'redux-duck'

import * as utils             from './utils'

import { myDuck as appDuck }    from './App'

export const myClass = 'EDIT_NAME_MODAL'

export const myDuck = createDuck(myClass, 'Edit_Name_Modal')

const INIT            = myDuck.defineType('INIT')
const ADD_CHILD       = myDuck.defineType('ADD_CHILD')
const SET_ROOT        = myDuck.defineType('SET_ROOT')
const REMOVE_CHILDS   = myDuck.defineType('REMOVE_CHILDS')
const REMOVE          = myDuck.defineType('REMOVE')
const SET_DATA        = myDuck.defineType('SET_DATA')

// init
export const init = (myId, query) => {
  return (dispatch, getState) => {
    dispatch(utils.init({myId, myClass, myDuck, ...query}))
    dispatch(utils.setRoot(myId, myClass, appDuck))
  }
}
github cofacts / rumors-site / ducks / articleList.js View on Github external
import { createDuck } from 'redux-duck';
import { fromJS, List, Map } from 'immutable';
import { waitForAuth } from './auth';
import gql from '../util/gql';
import { commonSetState } from '../util/reducer';

const COSTY_FIELD_COOLDOWN = 60 * 1000; // in seconds. query costy fields only 1 time within 60 seconds

const { defineType, createReducer, createAction } = createDuck('articleList');

// Action Types
//

const LOAD = defineType('LOAD');
const LOAD_AUTH_FIELDS = defineType('LOAD_AUTH_FIELDS');
const SET_STATE = defineType('SET_STATE');

// Action creators
//
export const setState = createAction(SET_STATE);

let isInCooldown = false;
let lastStringifiedFilter;
export const load = ({
  q,
github cofacts / rumors-site / ducks / auth.js View on Github external
/*global ga*/

import { createDuck } from 'redux-duck';
import { fromJS } from 'immutable';
import fetchAPI from '../util/fetchAPI';
import gql from '../util/gql';
import { commonSetState } from '../util/reducer';

const { defineType, createAction, createReducer } = createDuck('auth');

// Action Types
//
const LOAD = defineType('LOAD');
const RESET = defineType('RESET');
const SET_STATE = defineType('SET_STATE');
const UPDATE_USER = defineType('UPDATE_USER');

// Hacks (?)
//
let resolveAuth;
export const waitForAuth = new Promise(resolve => {
  resolveAuth = resolve;
});

// Action creators
github cofacts / rumors-site / ducks / articleDetail.js View on Github external
import { createDuck } from 'redux-duck';
import { fromJS, Map, List, Set } from 'immutable';
import { waitForAuth, loadLevel } from './auth';
import gql from '../util/gql';
import NProgress from 'nprogress';

const { defineType, createAction, createReducer } = createDuck('articleDetail');

// Action Types
//

const LOAD = defineType('LOAD');
const LOAD_AUTH = defineType('LOAD_AUTH');
const SET_STATE = defineType('SET_STATE');
const RESET = defineType('RESET');
const LOAD_SEARCH_OF_ARTICLES = defineType('LOAD_SEARCH_OF_ARTICLES');
const UPDATE_REPLY_REQUESTS = defineType('UPDATE_REPLY_REQUESTS');
const LOAD_SEARCH_OF_REPLIES = defineType('LOAD_SEARCH_OF_REPLIES');

// Action creators
//
const fragments = {
  articleFields: `
github ailabstw / pttai.js / src / reducers / ModalContainer.js View on Github external
import { createDuck } from 'redux-duck'

export const myClass = 'MODAL_CONTAINER'

export const myDuck = createDuck(myClass, 'Modal_Container')

const OPEN_MODAL = myDuck.defineType('OPEN_MODAL')
const CLOSE_MODAL = myDuck.defineType('CLOSE_MODAL')
const SET_SUBMIT = myDuck.defineType('SET_SUBMIT')
const SET_INPUT = myDuck.defineType('SET_INPUT')

const modalState = {
  currentModal: null
}

export const openModal = (modalType) => ({
  modalType,
  myClass,
  type: OPEN_MODAL
})
github Jerry-Hong / rx-devtools / src / app / reducers / sources.js View on Github external
import { createDuck } from 'redux-duck';
import { RESET_STORE } from '../../constants/index.js';

/**
 * duck
 */
const duck = createDuck('sourceList', 'rx-devtools');

/**
 * action types
 */
const ADD_SOURCE = duck.defineType('ADD_SOURCE');
const SUBSCRIBE_SOURCE = duck.defineType('SUBSCRIBE_SOURCE');

/**
 * action creators
 */

export const addSource = (name, createAt) =>
    duck.createAction(ADD_SOURCE)({ name, createAt });
export const subscribeSource = (name, subscribeAt) =>
    duck.createAction(SUBSCRIBE_SOURCE)({ name, subscribeAt });
github Jerry-Hong / rx-devtools / src / app / reducers / sourceItems.js View on Github external
import { createDuck } from 'redux-duck';
import {
    OBSERVABLE_COMPLETE,
    OBSERVABLE_ERROR,
    OBSERVABLE_NEXT,
    OBSERVABLE_UNSUBSCRIBE,
    RESET_STORE,
} from '../../constants/index.js';

/**
 * duck
 */
const duck = createDuck('sourceItems', 'rx-devtools');

/**
 * action types
 */
const RECEIVE_NEXT = duck.defineType('RECEIVE_NEXT');
const RECEIVE_ERROR = duck.defineType('RECEIVE_ERROR');
const RECEIVE_COMPLETE = duck.defineType('RECEIVE_COMPLETE');
const RECEIVE_UNSUBSCRIBE = duck.defineType('RECEIVE_UNSUBSCRIBE');

/**
 * action creators
 */
export const receiveNextValue = (sourceName, value, timestamp) =>
    duck.createAction(RECEIVE_NEXT)({ sourceName, value, timestamp });
export const receiveError = (sourceName, error, timestamp) =>
    duck.createAction(RECEIVE_ERROR)({ sourceName, error, timestamp });

redux-duck

Helper function to create Redux modules using the ducks-modular-redux proposal.

MIT
Latest version published 5 years ago

Package Health Score

45 / 100
Full package analysis

Popular redux-duck functions