GithubHelp home page GithubHelp logo

Singleton scope doesn't work about ray.di HOT 7 CLOSED

ray-di avatar ray-di commented on September 21, 2024
Singleton scope doesn't work

from ray.di.

Comments (7)

koriym avatar koriym commented on September 21, 2024

Thanks, @madapaja

from ray.di.

akkie avatar akkie commented on September 21, 2024

Hi,

this bug isn't fixed. If I get the instances over the Injector::getInstance() method, then the method returns the same instances. But the automatically injected instances, with the help of the @Inject annotation, are not the same instances.

Cheers,
Christian

from ray.di.

madapaja avatar madapaja commented on September 21, 2024

I sent the pull request for this issue.

In Injector::bindOneParameter(), I found a bug that it can't read annotation information by Config::fetch().
I guess this is because it call target class's config which is not enable to read Scope information. - typehint(interface) has binding(scope) information.

I've changed form Config::fetch($typehint) to Config::fetch($target) in Injector::bindOneParameter() to fix this issue.
All tests passed, although I'm not sure yet. So would you please confirm ?

Cheers.


自信が無いので日本語でも。。。
Injector::bindOneParameter() 内でアノテーションによるScope指定が読み取れない問題を見つけました。
これは、ターゲット(バインド先)クラスのconfigを呼んでいるため、Scope指定が読み取れないためだと思います。
(Scope指定は、Interface(タイプヒントされた)クラス内で行われているためです)

これを解決するために、Config::fetch($target)Config::fetch($typehint) に変更しました。
テストは通りますが、これでいいのかどうか自信がないので、ご確認ください。

from ray.di.

koriym avatar koriym commented on September 21, 2024

Thanks @madapaja as always. The code seems OK. I will try with BEAR.Sunday app as well.

from ray.di.

koriym avatar koriym commented on September 21, 2024

@akkie would you confirm it ?

from ray.di.

akkie avatar akkie commented on September 21, 2024

Yes, it works. I think the issue can be closed.

from ray.di.

koriym avatar koriym commented on September 21, 2024

Thank you all folks.

from ray.di.

Related Issues (20)

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.