Questions tagged [inversifyjs]

InversifyJS is a lightweight IoC container written in TypeScript.

InversifyJS is a lightweight pico inversion of control (IoC) container for TypeScript and JavaScript apps. A pico IoC container uses a class constructor to identify and inject its dependencies.

InversifyJS is easy to integrate with the majority of existing JavaScript frameworks and encourage the usage of the best OOP and IoC practices.

You can learn more about InversifyJS at http://inversify.io/

197 questions
2
votes
1 answer

inversify: how to bind Model to container object

I am developing an application using typescript, mean stack, inversify-express-utils and inversifyjs as my IOC container. I am receiving an error for my entries in the inversify.config.ts file for the entry that add a Model to the container. For…
user1790300
  • 2,143
  • 10
  • 54
  • 123
2
votes
1 answer

Best way to inject a function using InversifyJS

There's an official recipe to inject a function using InversifyJS. Basically, we define a helper function that will return a curried version of a given function func with all its dependencies resolved using container.get(...): import { container }…
Danziger
  • 19,628
  • 4
  • 53
  • 83
2
votes
1 answer

inversify: not injectable contrustor arguments

I have a Game class and a Multiplayer class which handle all network players stuff for defined game: export interface Multiplayer{ game: Game start() } export class WebSocketMultiplayer implements Multiplayer{ constructor(public game:…
SET001
  • 11,480
  • 6
  • 52
  • 76
2
votes
1 answer

IoC in React without typescript

I'm pretty new to React, and I would essentially have a service (one single instance) that I could somehow inject and use in multiple React components. So far, the options I've come across by googling were: Using React's context, but it's not…
Fabio Salvalai
  • 2,479
  • 17
  • 30
2
votes
1 answer

How can I export multiple object instances in TypeScript?

I am building a library in TypeScript that is using a dependency injection system (inversifyJS) to construct itself and resolve dependencies internally. The problem I have is - I want to expose multiple instances from the injection system to the…
Deniss B.
  • 281
  • 4
  • 13
2
votes
1 answer

How can I inject knex using inversify?

How can I initialise knex and use Inversify dependency injector to inject it in every where that i needed?
user4092086
  • 986
  • 3
  • 12
  • 24
2
votes
1 answer

Binding classes with property injection to kernel in inversify

I am trying to achieve dependency injection on my node project via inversify. I have a kernel config like this: inversify.config.ts import "reflect-metadata"; import {Kernel, interfaces} from "inversify"; import {Config} from "./config"; import…
Umut Benzer
  • 3,476
  • 4
  • 36
  • 53
1
vote
1 answer

InversifyJS - What is the difference between .to and .toService?

I'm confused by the documentation, which states that .toService(MyClass) is used for transitive bindings. But in the examples shown, i can achieve the same thing using a regular .to(MyClass) as…
Rmo
  • 61
  • 7
1
vote
0 answers

Dynamic injection based on request parameter/ header in controller using InversifyJS

I am exploring InversifyJS in TypeScript and I want to understand if InversifyJS will work for my use case. I have a TypeScript project with serverless lambda, Koa. I want to integrate InversifyJS and work on dynamic dependency injection, i.e., with…
1
vote
1 answer

Node.JS inversify constructor injection with @unmanaged

import { EntityTarget, Repository } from "typeorm" import { injectable, unmanaged, inject } from "inversify"; @injectable() export abstract class RepositoryBase implements IRepository { protected _repository:…
1
vote
1 answer

How to split code when using inversify js?

@injectable() class Ninja implements Warrior { @inject(TYPES.Weapon) private _katana: Weapon; @inject(TYPES.ThrowableWeapon) private _shuriken: ThrowableWeapon; public fight() { return this._katana.hit(); } public sneak() { return…
icy0307
  • 11
  • 3
1
vote
1 answer

How to inject multiple named dependencies using InversifyJS?

Let's imagine the following class hierarchy: interface Weapon { } interface BladedWeapon extends Weapon { } class Katana implements BladedWeapon { } class Stick implements Weapon { } Current bindings are…
briarheart
  • 1,906
  • 2
  • 19
  • 33
1
vote
0 answers

Mongoose Schema TypeScript Error + Index signature for type string is missing

I am using inversify in my express API for dependency injection and I am trying to define my schema using typescript 4.9.4 if I downgrade to 4.3.2 the error goes away but if possible I would love to figure this out. Interface export interface…
Jason McFarlane
  • 2,048
  • 3
  • 18
  • 30
1
vote
1 answer

TypeError: null is not an object (evaluating 'dispatcher.useMemo')

I'm trying to use InversifyJS with MobX in my React Native application but I got this error: ERROR TypeError: null is not an object (evaluating 'dispatcher.useMemo') I don't use useMemo anywhere. My application is almost empty, I've just…
ballarnes
  • 11
  • 1
1
vote
0 answers

Error: No matching bindings found for serviceIdentifier

I am working with a GLSP Node server and Diagram VScode extension in Typescript. When I try to launch the application, I am getting the following error: (node:36950) UnhandledPromiseRejectionWarning: Error: No matching bindings found for…