Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish async module APIs #697

Open
lemonmade opened this issue Feb 19, 2024 · 6 comments
Open

Polish async module APIs #697

lemonmade opened this issue Feb 19, 2024 · 6 comments

Comments

@lemonmade
Copy link
Owner

Some more ideas:

import {asyncModule} from '@quilted/async';
import {PreloadModule, asyncComponent} from '@quilted/react-async';

const myModule = asyncModule(() => import('./my-module'));
const myModuleUpdatedWithBundler = asyncModule(() => import('./my-module'), {
  id: 'my-module.abc123.js',
  cache: globalThis[Symbol.for('quilt')].moduleCache,
});

const componentModule = asyncModule(() => import('./MyComponent'));
const MyComponent = asyncComponent(componentModule);

const resolved = await myModule();
const resolved2 = await myModule.resolved;
const resolved3 = myModule.resolved.value;
const resolved3Error = myModule.resolved.error;

<PreloadModule module={myModule} />;
<MyComponent />;
@lemonmade
Copy link
Owner Author

@lemonmade
Copy link
Owner Author

@lemonmade
Copy link
Owner Author

@lemonmade
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant