Re: Injection problem in 0.8.0

79 views
Skip to first unread message

Chad Glendenin

unread,
May 1, 2013, 11:25:24 AM5/1/13
to def...@googlegroups.com
Can we see your Deft Injector configuration?


On Wed, May 1, 2013 at 10:16 AM, <marcin...@gmail.com> wrote:
I have a simple app with only a few classes.

- controller
--- SearchController.js

- model
--- BookModel.js, SearchModel.js, ResultsModel.js

- store
--- BookStore.js

- view
--- a few views, not important at this point

I have injection enabled in SearchController, ResultsModel and in the views. It works fine except ResultsModel:

Ext.define('RM.model.ResultsModel', {
   extend: 'Ext.data.Model',
   inject: ['bookStore'],

   config: {
      bookStore: null
   }

   update: function (collection) {
      this.bookStore.loadData(collection);
   }
});

The this.bookStore reference is either
 * null (with config section)
 * or some weird object that has no loadData method (when I remove the 'config' section)

Can there be anything I am doing wrong or is this simply a bug?

Thanks,
Marcin

--
You received this message because you are subscribed to the Google Groups "Deft JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deftjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brian Kotek

unread,
May 1, 2013, 11:31:31 AM5/1/13
to deftjs
Model extends Base, so there's probably nothing that calls initConfig(), which may be the issue with using config. Without config, what is the actual "weird" object being injected?

Brian Kotek

unread,
May 1, 2013, 12:01:26 PM5/1/13
to deftjs
Also, can you successfully inject and use the bookStore in other objects?

marcin...@gmail.com

unread,
May 1, 2013, 1:58:57 PM5/1/13
to def...@googlegroups.com
This is part of my Application.js:

   init: function () {
      this.beforeInit();
      Deft.Injector.configure(this.buildInjectorConfiguration());
      return this.afterInit();
   },

   buildInjectorConfiguration: function () {
      var config;
      config = {
         bookStore: 'RM.store.BookStore',
         searchModel: 'RM.model.SearchModel',
         resultsModel: 'RM.model.ResultsModel',
         searchService: 'RM.service.SearchService'
      }
      return config;
   },

Everything used in the application is here.

marcin...@gmail.com

unread,
May 1, 2013, 2:05:06 PM5/1/13
to def...@googlegroups.com
Without config, the object has __proto__ set to TemplateClass which has properties like BookStore, but does not respond to loadData method (sorry, I am no javascript expert).

I am getting:
Uncaught TypeError: Object [object Object] has no method 'loadData'

Brian Kotek

unread,
May 1, 2013, 2:16:54 PM5/1/13
to deftjs
Again, can you inject bookStore into other objects and use it? Is the problem only with this one injection in this one Model object?

Also, are you using ExtJS 4.2?

marcin...@gmail.com

unread,
May 1, 2013, 2:25:32 PM5/1/13
to def...@googlegroups.com
I can't inject bookStore anywhere. There is the same problem and it is the only injection I am having problem with.

I am using Ext 4.1.1

Brian Kotek

unread,
May 1, 2013, 2:35:31 PM5/1/13
to deftjs
Really not sure then. I inject Stores into other objects all the time. 

If you haven't, try creating a new instance of the store yourself (via Ext.create()) and check it, because it sounds to me like there's something wrong with your Store. You might also try using ext-all-dev and checking the console to see if the DeftJS log shows the dependencies being created and injected, as well as looking for any errors. It might not hurt to post the code for the Store as well.

If, after that, it still doesn't work, you can create a simple test case with just the Store and a basic view. Inject the store into the view to demonstrate the problem. Then zip it up and attach it, and I can try to take a look at what you're doing.

marcin...@gmail.com

unread,
May 1, 2013, 4:36:02 PM5/1/13
to def...@googlegroups.com
I tried what you suggested and the problem was with my store. A small typo I could not see.

Sorry for trouble :)
Reply all
Reply to author
Forward
0 new messages