Skip to content

Instantly share code, notes, and snippets.

@CharlieHess
Last active September 28, 2017 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlieHess/868b34fd8702930570672cc36bdef45c to your computer and use it in GitHub Desktop.
Save CharlieHess/868b34fd8702930570672cc36bdef45c to your computer and use it in GitHub Desktop.
A redux-observable epic that handles first time sign-in
import { BrowserWindow } from 'electron';
import { REHYDRATE } from 'redux-persist/constants';
import { getWorkspacesCount } from '../reducers/workspaces';
const signInWindowEpic = (action$, store) => {
// Rehydrate is just a $10 word for "we loaded saved state from a file"
// Since we're a redux-persist app, it's one of the first actions that occurs
return action$.ofType(REHYDRATE)
.filter(() => getWorkspacesCount(store) > 0)
.map(() => createSignInWindow(store))
.do((browserWindow) => browserWindow.show());
};
function createSignInWindow(store) {
const browserWindow = new BrowserWindow( /* ... you get the idea */ );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment