Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created May 17, 2022 14:16
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 jasonLaster/204607bb076148309ed198e060b7714b to your computer and use it in GitHub Desktop.
Save jasonLaster/204607bb076148309ed198e060b7714b to your computer and use it in GitHub Desktop.
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