You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying this as a last ditch effort to do something that i don't think Storybook is designed to handle.
I have an app that has recently been built up by Angular developers in Lit. The app is bootstrapped with a custom built DI so that all Injectable props default to the type they are assigned but a different implementation can be provided (I assume that this is just for testing).
The problem I'm seeing is that there is no way I can seem to find to initialize the DiContainer before storybook is ready to serve the stories (hopefully my word usage is correct there). I've tried using decorators, loaders, and globals at the preview.ts level, but those run after the code has already been (transpiled into memory?).
I'll include a VERY simple sample of my problem, reproducing anything like the whole would be impossible.
Additional information
export class ProblemComponent extents BaseComponent {
...stuff that isn't the issue
}
export abstract class BaseComponent {
// Here is what the custom DI code uses to identify a prop that needs DI
// Here also is where the issue is, the DI container was never initialized so it doesn't have an implementation to provide here
@InjectProperty()
private declare readonly someService: SomeDefaultServiceImplementation;
}
//Here is the code that i need to run somewhere
await DiContainer.init();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
I am trying this as a last ditch effort to do something that i don't think Storybook is designed to handle.
I have an app that has recently been built up by Angular developers in Lit. The app is bootstrapped with a custom built DI so that all Injectable props default to the type they are assigned but a different implementation can be provided (I assume that this is just for testing).
The problem I'm seeing is that there is no way I can seem to find to initialize the DiContainer before storybook is ready to serve the stories (hopefully my word usage is correct there). I've tried using decorators, loaders, and globals at the preview.ts level, but those run after the code has already been (transpiled into memory?).
I'll include a VERY simple sample of my problem, reproducing anything like the whole would be impossible.
Additional information
export class ProblemComponent extents BaseComponent {
...stuff that isn't the issue
}
export abstract class BaseComponent {
// Here is what the custom DI code uses to identify a prop that needs DI
// Here also is where the issue is, the DI container was never initialized so it doesn't have an implementation to provide here
@InjectProperty()
private declare readonly someService: SomeDefaultServiceImplementation;
}
//Here is the code that i need to run somewhere
await DiContainer.init();
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions