question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing params to Container.get() or Container.of()

See original GitHub issue

In the inline documentation, the Container.get() method says the following:

Retrieves the service with given name or type from the service container. Optionally, parameters can be passed in case if instance is initialized in the container for the first time.

Emphasis mine. It didn’t seem like this was accurate, as there was no overload that seemed to support this. I did a little research, and discovered that this feature did indeed exist at one point, but was removed seemingly without any communicated justification in this commit: https://github.com/typestack/typedi/pull/18/commits/79f3435f42502ee2410052c7e0391eb94fd689f0.

So I am here to ask- what was the justification? Is there a replacement for the use-cases this supported?

The main use-case I am looking for is for passing parameters to factories of transient instances, so I can configure them on a per-request basis.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jaschaiocommented, Jun 24, 2020

@pleerock any chance to get any insights from you on the topic? My workaround is not really a suitable alternative to just passing parameters to Container.get().

2reactions
jaschaiocommented, Jun 21, 2020

Having the exact same question as @weoreference. Taking a look at the code it seems like its not currently possible to pass parameters to the constructor. I tried withregisterHandler but without luck.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing parameters to Docker container - Stack Overflow
EDIT : Adding a basic example to demonstrate how to get parameters from command line. #cat Dockerfile FROM ubuntu:14.04 ENTRYPOINT ["/bin/ping"].
Read more >
Understanding Docker Build Args, Environment Variables and ...
An overview of ways to set and use variables when building images, starting containers and using docker-compose.
Read more >
Passing Environment Variables to Docker Containers
In this tutorial, we'll achieve this by passing environment variables to a Docker container. 2. Using –env, -e.
Read more >
Define a Command and Arguments for a Container - Kubernetes
This page shows how to define commands and arguments when you run a container in a Pod. Before you begin. You need to...
Read more >
docker run - Docker Documentation
The docker run command first creates a writeable container layer over the specified image, ... GPU devices to add to the container ('all'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found