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

gizmo: dynamic loader #161

Open
unional opened this issue Apr 9, 2023 · 1 comment
Open

gizmo: dynamic loader #161

unional opened this issue Apr 9, 2023 · 1 comment

Comments

@unional
Copy link
Owner

unional commented Apr 9, 2023

const loader = (gizmos: Gizmo[], result: AnyRecord) => (identifier: string) => Promise<AnyRecord>

incubator().with(...).create(loader)

Only when there are dynamic dependencies.

UPDATE:

to work with #186:

incubator().with(...).create((gizmo, ctx) => {
  ctx.setDynamicLoader(...)
  return () => clean up
}

or

// only set once and remove from the chain
incubator().loader().with(...).create()
@unional
Copy link
Owner Author

unional commented May 9, 2023

There are 3 options to add the loader:

  • before: incubate().loader({ ... }).with(...).create() - not preferred as there is no way to type the loader.
    (alternative incubate(init, { loader: { ... } }).with(...).create())
  • after: incubate().with(...).loader({ ... }).create() - can type the loader, and can add loader along with the incubator. However, do not know what is the use case of adding loader with the incubator. And it makes the logic quite difficult, as now we need to exclude or able to override what's already in the incubator.
  • on creation: incubate().with(...).create((g, ctx) => { ctx.setLoader({ ... }) }) - can type the loader. Down side is the loader need to be specified on every creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant