PenguLoader / PenguLoader

✨ The ultimate JavaScript plugin loader, build your unmatched LoL Client.
https://pengu.lol
Do What The F*ck You Want To Public License
346 stars 56 forks source link

[Core] Add `blocking` optional param to `rcp.postInit` #80

Closed BakaFT closed 8 months ago

BakaFT commented 8 months ago

should update beta docs later if merged.

nomi-san commented 8 months ago

You should wrap the callback inside a function to control non-/blocking without removing await keyword, so there is no much code!

// add blocking callback
map.push(callback);

// add non-blocking callback
map.push(() => (callback(), void 0));

// trigger the callback
await callback();

Estimated about < 5 line changes for this feature.

BakaFT commented 8 months ago

fancy await . working fine now.

export function init(context: PenguInitContext) {
  // wait 5s after ember-libs init
  context.rcp.postInit(
    "rcp-fe-ember-libs",
    async () => {
      await new Promise(r => setTimeout(r, 5000));
    },
    true
  )
}