I\'m pretty new to Aurelia (only been using it a few days) and I love it!
I know how to make a service with Aurelia, but how can I make that service a singleton that
So I realized I was thinking about this too hard. I was trying to depend on the framework (Aurelia) to do all the work, but actually it was a simple ES6 class change that makes it an instance.
let instance = null;
export class SingletonService {
constructor() {
if(!instance) {
instance = this;
}
return instance;
}
}
Just inject it
By default, the DI container assumes that everything is a singleton instance; one instance for the app. However, you can use a registration decorator to change this.