Skip to content

Instantly share code, notes, and snippets.

@avivshafir
avivshafir / injectingAsyncReducers.ts
Last active March 5, 2018 19:16
Injecting Async Redux Reducers
export function injectAsyncReducer(store, name, asyncReducer) {
if (store.asyncReducers[name]) {
return;
}
store.asyncReducers[name] = asyncReducer;
store.replaceReducer(createReducer(store.asyncReducers));
}
export const configureStore = (initialState: AppState) => {
const enhancer = compose(applyMiddleware(...getMiddleware()));
@avivshafir
avivshafir / combineReducers.tsx
Last active March 5, 2018 19:04
adding redux form reducer to our app reducers
import { reducer as formReducer } from "redux-form";
const applicationReducer: Reducer<any> = combineReducers({
user,
sidenav,
navigation,
//...
form: formReducer
});
@avivshafir
avivshafir / tsconfig.json
Last active March 5, 2018 17:04
tsconfig for dynamic imports
{
"compilerOptions": {
"target": "es5",
"sourceMap": false,
"inlineSourceMap": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"preserveConstEnums": true,
"removeComments": false,
@avivshafir
avivshafir / generateTagsReactLoadable.js
Last active March 5, 2018 17:30
Using React Loadable for lazy loading our GenerateTags component
const GenerateTags = Loadable({
loader: () =>
import(/* webpackChunkName: "generateTags" */ "./GenerateTags"),
loading: LoadingSpinner
});
@avivshafir
avivshafir / webpack.js
Last active March 5, 2018 18:34
webpack 4 loading vendors into vendor.js and generating a manifest file which includes the webpack runtime
mode: "production",
entry: {
app: path.join(__dirname, "index.tsx"),
},
output: {
path: path.resolve(__dirname, "public/dist"),
publicPath: "",
chunkFilename: "[name].js",
filename: "[name].js"
},
@avivshafir
avivshafir / alfy_alfred_node_workflow.js
Last active February 19, 2018 21:04
Alfy | Alfred workflow node example
const alfy = require("alfy");
const alfyFetchOptions = {
auth: auth,
maxAge: requestCacheInMilis
};
const auth = "username:password";
const requestCacheInMilis = 1000 * 60 * 60 * 24; //24 hours