Created
May 17, 2022 14:16
-
-
Save jasonLaster/204607bb076148309ed198e060b7714b to your computer and use it in GitHub Desktop.
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 { dispatch } from "rxjs/internal/observable/pairs"; | |
type Context = { | |
loadCount: number | |
} | |
function bootstrap() { | |
// ... | |
threadFront.on("loaded", () => store.dispatch(onLoaded())) | |
} | |
export function onLoaded() { | |
return (dispatch, getState) => { | |
const existingContext = getContext(getState()) | |
const cx: Context = dispatch({type: "loaded", loadCount: existingContext.loadCount++}); | |
const printStatements = getPrintStatements(getState()); | |
const loadedRegions = getLoadedRegions(getState()) | |
for (const printStatement of printStatements) { | |
if (shouldUpdatePrintStatment(printStatement, loadedRegions)) { | |
dispatch(updatePrintStatement(printStatement)); | |
} | |
} | |
} | |
} | |
function updatePrintStatement(printStatement, cx) { | |
return (dispatch, getState) => { | |
// clear the print statements existing analysis | |
// kick off a new analysis | |
// ... | |
// when the analysis comes back check to see if the context has not changed | |
// store the analaysis in the store so that it is ready | |
} | |
} | |
function shouldUpdatePrintStatment(printStatement, loadedRegions) { | |
// check if the new loadedRegions contains the printStatement's region | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment