Last active
December 28, 2017 18:01
-
-
Save bmeck/da301cdf4e561747aafa462bff080172 to your computer and use it in GitHub Desktop.
creates a cycle to intentionally ensure only `a` can run `b`
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 {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; | |
// ... | |
}; |
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 {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