I'd like to make a third-party object on the window injectable so that I can test functionality independent of the third-party service. The component I'm trying to build is a simple wrapper around Disqus embedded comments. The factory I would like to use is as simple as
() => window.DISQUS
Has anyone been able to do this or know if it is possible?
Use registerInstance with a string key like this:
container.registerInstance('disqus', window.DISQUS);
Then you can inject the disqus instance into your view models like this:
import {inject} from 'aurelia-framework';
@inject('disqus')
export class Foo {
constructor(disqus) {
this.disqus = disqus;
}
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With