Comments (10)
I'll check this out myself.
from dependency-injection.
Confirmed that placing singleton()
on a view model works as expected, at least in the master.
from dependency-injection.
Do you have an example?
Placing @singleton()
or @singleton(false)
? because a few releases ago it was @singleton(false)
.
Any idea what could influence this? Because it definitely does not work in my code base on current release and I'm 100% sure it previously did.
from dependency-injection.
I am pretty sure it does not work -- or I don't understand how it's intended to work.
I have done some debugging and it seems the breaking change is here:
5e2b75b#diff-dcf9a6cedb6d0d9a360cc92ddaa1c0c2L52
Before commit #5e2b75b, the singleton createResolver
used to return a root singleton when registerInChild
was false and such a singleton already existed.
After the change, a new resolver is always created and returned. It is then registered at root (kinda) but that doesn't really matter... since the already existing singleton resolver at root is not returned, a new instance has to be created.
I think that's why my view are recreated every time.
from dependency-injection.
@jods4 Today will probably by a pre-beta release, perhaps is solved here
from dependency-injection.
Maybe, but doubtful as the sources I was looking at are master
and they don't seem fundamentally different from what I'm running.
If there's a pre-beta release coming, I think this should be double-checked ASAP before the release because it's a major bug, that's worthy of being fixed for that release.
from dependency-injection.
There was a bug in the DI in the last released. It has been fixed. I tested this myself by simply placing @singleton()
on the welcome view model in the navigation-skeleton app.
from dependency-injection.
Can you refer the fixing commit? I need to patch this today.
from dependency-injection.
ca5ccf7#diff-dcf9a6cedb6d0d9a360cc92ddaa1c0c2R94
Getting the latest master will require the latest of metadata also...but that is going to break everything else. So, just wait for a little bit. We are going to try to get a pre-beta release out today.
from dependency-injection.
I managed to patch around this bug but I had to do it a very ugly way. When I tried to apply the changes you linked above, the result was still the same (i.e. not reusing the same VM for the whole app). But maybe that was because I was missing other relevant bits.
I'll test with the new release and report if it doesn't work.
from dependency-injection.
Related Issues (20)
- @lazy not working with @autoinject HOT 7
- get rid of aurelia-pal dependency HOT 2
- Optional resolver doesn't work as expected HOT 2
- Proposal for easier way to inject via DI into a view-model HOT 10
- di, nodejs HOT 4
- Missing property in d.ts? HOT 5
- Arrays and the DI Container HOT 26
- Version 1.4.0 does not contain the dist directory HOT 6
- 1.4.0 release and typings. HOT 3
- Unable to jspm bundle aurelia-dependency-injection 1.4 HOT 4
- Injecting a string resolves an empty string instead of undefined HOT 3
- Bug: Cannot use spread with the injector (Injection With Inheritance in Aurelia) HOT 19
- No access to global Container when used in node npm module HOT 5
- 1.4.2 release typings HOT 25
- error TS1005: ';' expected in TS typings HOT 1
- dependency-injection 1.5.0 incompatible to aurelia-validation 1.4.0 HOT 9
- error TS1110: Type expected HOT 6
- Building project in babel-loader fails on const enum because of --isolatedModules flag HOT 1
- Bug: @newInstance() becomes container default instance if it's the first instance
- Backport `resolve` from Aurelia 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dependency-injection.