Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with registration #349

Open
ciaoben opened this issue Jun 23, 2015 · 6 comments
Open

Problem with registration #349

ciaoben opened this issue Jun 23, 2015 · 6 comments

Comments

@ciaoben
Copy link

ciaoben commented Jun 23, 2015

Hi, I am upgrading to 0.10 and I have a problem with registration:

my Application js:

var Application = Marty.createApplication(function () {
  this.register(require('./stores'));
  this.register(require('./actions'));
  this.register(require('./queries'));
  this.register(require('./sources'));
  this.router = require('./router');
});

my ./queries index.js:

module.exports = {
  appQueries: require('./appQueries'),
  settingsQueries: require('./settingsQueries')
};

But in my store:

module.exports = Marty.createStore({
  id: 'AppStore',
  handlers: {
    login: AppConstants.LOGIN,
    logout: AppConstants.LOGOUT,
    redirect_to_login: AppConstants.REDIRECT_TO_LOGIN,
    isLogged: AppConstants.IS_LOGGED,
  },
  getInitialState: function () {
    //AppQueries.isLogged();
    console.log("state test", this.app.appQueries.method());
  },
...

The console.log gives me "TypeError: Cannot read property 'method' of undefined".

What I am missing?

@jhollingworth
Copy link
Contributor

So on the surface that looks fine. Could you do a console.log(Object.keys(this.app)) to see what is registered?

@ciaoben
Copy link
Author

ciaoben commented Jun 23, 2015

@jhollingworth

Here is the output:

["__isApplication", "__isCoreType", "__types", "req", "res"]

But if I print console.log(this.app); and inspect it with the Chrome dev tools:

oggi

@jhollingworth
Copy link
Contributor

thats a bit spooky, and console.log(this.app.appQueries) returns undefined?

@ciaoben
Copy link
Author

ciaoben commented Jun 23, 2015

@jhollingworth yes

@ciaoben
Copy link
Author

ciaoben commented Jun 23, 2015

@jhollingworth

Here is my code, hope you can help me because I am stuck!

https://github.com/ciaoben/temp_debugging

I am upgrading from previous version, so there is a bit of mess, but the core should be fine!

@ciaoben
Copy link
Author

ciaoben commented Jun 23, 2015

@jhollingworth
I've tried to put a console.log in my index.js, to see if it is executed before my store, but apparently it is not. What could it be? How can I force my index.js to execute first. I am using browserify

EDIT

It is definitevely this. I have put a console.log in my store's getInitialState, and one in the the index.js where I instantiate the app, and the the one in the store it is executed first.

But I cannot get, where is my mistake???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants