Skip to content

Calling the same function with same argument however it's still not equal #16

@undefined-moe

Description

@undefined-moe
import { Context, Service } from 'cordis';

declare module 'cordis' {
    interface Context {
        foo: FooService;
    }
}

const app = new Context();

class FooService extends Service {
    registry = { };
    constructor(ctx) {
        super(ctx, 'foo', true);
    }
    register(name, value) {
      if (this.registry[name] && this.registry[name] !== value) throw new Error();
      this.registry[name] = value;
    }
}

app.plugin(FooService);
app.plugin({
    inject: ['foo'],
    apply(ctx) {
        function bar() { }
        ctx.foo.register('example', bar); // ok
        ctx.foo.register('example', bar); // throws
    },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions