Skip to content

Instantly share code, notes, and snippets.

@bmeck
Last active December 28, 2017 18:01
Show Gist options
  • Save bmeck/da301cdf4e561747aafa462bff080172 to your computer and use it in GitHub Desktop.
Save bmeck/da301cdf4e561747aafa462bff080172 to your computer and use it in GitHub Desktop.
creates a cycle to intentionally ensure only `a` can run `b`
import {ran} from 'b';
let ready;
// this function can be saved to a variable, but blows up if `b` has not run yet
export function onlyAvailableIfBHasRun() {
ready;
ran;
// ...
};
import {onlyAvailableIfBHasRun} from 'a';
// ready to init
export const ran = null;
onlyAvailableIfBHasRun();
// ... do side effects ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment