Skip to content

Instantly share code, notes, and snippets.

View bingex's full-sized avatar

Roman Datsiuk bingex

  • Newfire Partners
  • Ukraine
View GitHub Profile
@bingex
bingex / 0_reuse_code.js
Created August 12, 2016 08:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am bingex on github.
  • I am bingx (https://keybase.io/bingx) on keybase.
  • I have a public key ASCkejjmng2ihTSgniZFzdNdy08gWaNcjv7d7PV1Lr5mlQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am bingex on github.
  • I am bingx (https://keybase.io/bingx) on keybase.
  • I have a public key ASAmC2GBWQ-viLzs6RefraqCMuWYx9CP-sV3MVNZqABxdQo

To claim this, I am signing this object:

import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { createWrapper } from 'next-redux-wrapper';
import rootReducer from './rootReducer';
import rootSaga from './rootSaga';
export const makeStore = () => {
// 1: Create the middleware
const sagaMiddleware = createSagaMiddleware();
import { wrapper } from 'store';
const MyApp = ({ Component, pageProps }) => {
return <Component {...pageProps} />;
};
export default wrapper.withRedux(MyApp);
import React from 'react';
import { END } from 'redux-saga';
import { getProjectsWithPosts } from 'components/ProjectList/redux/actions';
import { wrapper } from 'store';
const Projects = () => {
return (
<ProjectList />
);
};
import { HYDRATE } from 'next-redux-wrapper';
const initialState = {
// initial state here ...
};
const projectsReducer = (state = initialState, action) => {
switch (action.type) {
// This will overwrite client state
case HYDRATE: {
import React from 'react';
import { useSelector } from 'react-redux';
import ProjectSection from './ProjectSection';
const ProjectList = () => {
const projects = useSelector(state => state.projectsReducer.projects);
return (
<div>
{projects.map(project => {
@bingex
bingex / post-cancel-requests-redux-saga__watcherSaga.js
Last active April 5, 2021 20:47
Watcher saga to stop upload request
import {takeEvery, fork, take} from 'redux-saga/effects';
export default function* watcherSaga() {
while (true) {
const forkedTask = yield fork(uploadMediaWorker, yield take(types.UPLOAD_MEDIA));
yield takeEvery(types.STOP_UPLOAD_MEDIA, stopUploadMediaWorker, forkedTask);
}
}
import {cancel} from 'redux-saga/effects';
function* stopUploadMediaWorker(action) {
yield cancel(action);
}