ember のレジスタと注入について理解を深めようとしています。基本的に、私のコードは次のようになります。
//creating a service
Nerdeez.Wormhole = Ember.Object.extend({
...
})
//registering this service as a singleton
App.register('wormhole:current', Nerdeez.Wormhole, {singleton: true});
//wanting to inject this service to be available everywhere in my application
//especially in the adapter where i use it in the ajax hook
App.inject('App', 'wormhole', 'wormhole:current');
//when trying to access this service in the ajax hook in the adapter i get undefined WTF!
App.get('wormhole') === undefined //true
このサービスをシングルトンとしてアプリケーション全体でグローバルに利用できるようにしたいのですが、これを実現する最善の方法は何ですか? サービスをモデル、ビュー、およびコントローラーに注入することに成功し、問題はそれをアダプターに注入することであると言うことが重要です。
前もって感謝します