Last active
September 28, 2017 02:50
-
-
Save CharlieHess/868b34fd8702930570672cc36bdef45c to your computer and use it in GitHub Desktop.
A redux-observable epic that handles first time sign-in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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