-
-
Save epixa/06c8eeabd99da3c7545ab295e49acdc3 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
let internalCoreReference; | |
export function __initCore__(core) { | |
if (internalCoreReference) { | |
throw new Error('Core already set'); | |
} | |
internalCoreReference = core; | |
} | |
export function getCore() { | |
if (!internalCoreReference) { | |
throw new Error('Core not set'); | |
} | |
return internalCoreReference; | |
} |
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
class Plugin { | |
setup(core) { | |
require('./core-hackery').__initCore__(core); | |
core.applications.register({ | |
id: 'foo', | |
async mount(domElement) { | |
const bootstrapApp = await import('./application'); | |
return bootstrapApp(domElement); | |
} | |
}); | |
} | |
} |
where do i put the core-hackery.js
file? In public or server code?
It seems that it is on the server
code. I'm confused how I can use it inside hacks
code?
This example is all client-side new platform plugins. It's not directly applicable to a legacy plugin since that doesn't have a controlled lifecycle.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and consumer: