Closed nomi-san closed 4 months ago
This trick may fix that.
export function init(context) {
context.rcp.preInit('rcp-fe-common-libs', async (provider) => {
window.provider = provider
})
setTimeout(async () => {
const api = await window.provider.getOptional("rcp-fe-lol-social")
console.log(api)
// fix me
}, 10000)
}
It should be noted that getOptional
will actually load plugin if its not loaded yet, which might not be ideal. I think to clear up any confusion there should be separate APIs to wait for a plugin (which will of course also instantly fire a callback if its already loaded when its called) and separate API to load them like load
/getOrLoad
.
This issue just marks a note for next update.
The current whenReady
impl wraps the callback inside Promise
, no checks for even loaded plugins.
Never saw getOptional
before, and it could be changed in the future.
That was lacking in v1.1.0.