@Inject decorator doesn't seem to work
See original GitHub issueThe @Inject
decorator doesn’t seem to work (at least not on a component, which is where I’m testing it).
Just a stab in the dark, but I wonder if this is possibly related to replacing your custom decorator with typedi’s decorator in PR https://github.com/sascha245/vuex-simple/pull/4?
/// SimpleModule.ts
import { Mutation, Module, Getter, State, getStoreBuilder } from 'vuex-simple';
@Module('simple')
export default class SimpleModule
{
@State() surname = "Baggins";
@Getter()
public get formalName()
{
return `Mr. ${this.surname}`
}
@Mutation()
public changeName(newName: string)
{
this.surname = newName;
}
}
/// RootComponent.ts
import { Inject } from "typedi";
import Component from "vue-class-component";
import Vue from "vue";
import SimpleModule from "./store/simple/SimpleModule";
@Component({
template: `
<div style='background: aliceblue; width: 80%; min-height: 100px'>
{{ formalName }}
</div>
`})
export default class RootComponent extends Vue
{
/// THIS PROPERTY IS "undefined"
@Inject()
simpleModule: SimpleModule
get formalName() {
return this.simpleModule.formalName
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Nest.js Injector decorator doesn't seem to register service ...
The service seems to inject correctly, but it does not resolve the dependencies inside the service, leaving me quite confused. Is it possible...
Read more >Inject() doesn't work, Container.get() does · Issue #93
Hi, I'm facing weird issue, Container.get(MyServiceName); returns demanded service, yet class property decorated with @Inject() is undefined ...
Read more >Dependency Injection using Decorators | by Chidume Nnamdi
We now see that when ReflectiveInjector creates instances it uses the metadata to deduce class dependencies.
Read more >How to Use the @Injectable Decorator in Angular
The @Injectable decorator together with the 'providedIn' option means the service should not be added within the providers' array of a module.
Read more >Angular & Dependency Injection: tricks with Decorators
The SkipSelf Decorator doesn't look for the dependency in the current injector and starts from the parent injector (and then continues to go ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reverted back for now, so we will have to do with the custom Inject provided by vuex-simple. At least with this Inject should now be usable again until I find a good way to make typedi’s Inject work.
Sorry for being late, was having my lunch. Did you eventually forget the “Vue.use(VuexSimple)”? It is necessary as it installs a Vue mixin that handles the injection of your modules / services in Vue components.