Git Product home page Git Product logo

deninject's People

Contributors

brmcerqueira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

deninject's Issues

Basic example does not work

Hi!

I just tried to use this library and it gives me "random" errors...

So I tried the basic example ad it just fails.

deno run -A test.ts

Warning Implicitly using latest version (1.0.5) for https://deno.land/x/deninject/mod.ts
error: Uncaught Error: Bind not found for 'ClassB'.
            throw new BindError(identity, token);
                  ^
    at Injector.privateGet (https://deno.land/x/[email protected]/injector.ts:248:19)
    at Injector.get (https://deno.land/x/[email protected]/injector.ts:220:21)
    at file:///Users/obioscaa/Documents/_Curro/_T2C/_PoC/_deno_cucumber/test.ts:28:20

Just to be clear, the copy-paste example tested is:

import { Injector, Singleton, Transient } from "https://deno.land/x/deninject/mod.ts"; 

class ClassA {
    constructor() {
        console.log("buildA");
    }
}

class ClassB {
    constructor(a: ClassA) {
        console.log("buildB: ", a);
    }
}

class MyModule {
    @Singleton()
    public buildA(): ClassA {
        return new ClassA();
    }

    @Transient()
    public buildB(a: ClassA): ClassB {
        return new ClassB(a);
    }
}

const injector = new Injector(new MyModule());
const b = injector.get(ClassB);

My tsconfig.json is...

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

... as specified in the docs here => https://deno.land/x/[email protected]#setup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.