InversifyJS icon indicating copy to clipboard operation
InversifyJS copied to clipboard

Support for request scope on fluentProvider

Open gustavolanna opened this issue 3 years ago • 1 comments

Summary:

I'm currently using request scopes on my project and I'd like to start using the decorators, but it seems there is no support for request scope in the library.

Expected Behavior

I'd like to use the request scope on the decorated classes.

Current Behavior

The class ProvideInSyntax just has methods for singleton and transient scope, but no support for request scope.

Possible Solution

Add a new method to this class to support in request scope

    public inRequestScope(): interfaces.ProvideWhenOnSyntax<T> {
        let bindingWhenOnSyntax = (bind: inversifyInterfaces.Bind, target: any) => this._bindingInSyntax(bind, target).inRequestScope();
        let inDoneSyntax = new ProvideDoneSyntax(bindingWhenOnSyntax);

        let provideWhenSyntax = new ProvideWhenSyntax<T>(bindingWhenOnSyntax, inDoneSyntax);
        let provideOnSyntax = new ProvideOnSyntax<T>(bindingWhenOnSyntax, inDoneSyntax);
        return new ProvideWhenOnSyntax(provideWhenSyntax, provideOnSyntax);
    }

gustavolanna avatar Feb 04 '22 18:02 gustavolanna

Is there any workaround for this issue?

Seems like there exists a PR already.

Anything we can help?

tlyau62 avatar Mar 22 '22 05:03 tlyau62