Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add api exposing a hook-based way to load a module#976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
edkimmel wants to merge2 commits intogregberge:main
base:main
Choose a base branch
Loading
fromedkimmel:hook-api

Conversation

@edkimmel
Copy link
Contributor

Summary

Adds loadable.hook and lazy.hook as additional ways to load a dynamic module via@Loadable

A common use case is to use some large third party library as part of a hook in first party code. By exposing a hook-based API in@Loadable, it becomes trivial to dynamically load that library module.

const useThirdPartyAuthSdk = loadable.hook(() => 'some-large-sdk')...const useUserSignIn = () => {  // 'some-large-sdk' is not loaded until this hook is ran  const thirdPartyAuthSdk = useThirdPartyAuthSdk()  const signin = React.useCallback(creds => {    if (!thirdPartyAuthSdk) throw new Error('Auth SDK used before ready')    thirdPartyAuthSdk.initiateSignin(creds)  }, [thirdPartyAuthSdk])  return {    ready: !!thirdPartyAuthSdk,    signin  }}

Test plan

loadableHook.test.js has been created mirroringloadable.test.js where applicable.
An example for the hook api was created in the repository.

@theKasheytheKashey self-requested a reviewAugust 26, 2023 01:14
@theKashey
Copy link
Collaborator

Amazing job and quite interesting implementation. Big kudos for comprehensive tests.

However, let me be clear - I am going to add this PR to the list of all other things one way or another assigned to me and I cannot provide you any ETA for actual resolution. My presence in GitHub lands is quite limited nowadays.

knight10-ux and edkimmel reacted with thumbs up emojiknight10-ux reacted with eyes emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@theKasheytheKasheyAwaiting requested review from theKashey

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@edkimmel@theKashey

[8]ページ先頭

©2009-2025 Movatter.jp