import { Action } from 'vuex-simple'
import { Inject, Injectable } from 'vue-typedi'
import tokens from '~/logic/tokens'
import CommentService from '~/logic/comments/services/api'
@Injectable() // required to make class injectable (to have injections)
@Inject(tokens.COMMENT_SERVICE) // tokens.COMMENT_SERVICE is a unique name
public service!: CommentService // we can also type the injected service
public async fetchComments () {
// Here we use injected service, without explicitly passing it:
const commentsList = await this.service.fetchComments()
import { Service } from 'vue-typedi'
import tokens from '~/logic/tokens'
// Here we register our service under a unique name,
// it will be used to inject it later:
@Service(tokens.COMMENT_SERVICE)