Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // my component
- var App = React.createClass({
- getInitialState: function() {
- CustomerQueries.isLogged();
- return {};
- },
- render () {
- //here my markup
- }
- });
- // my cointainer
- App = Marty.createContainer(App ,{
- listenTo: CustomersStore,
- fetch: {
- auth: function () {
- console.log("I am here!!!!"); // ---->>> it doesn't arrive here! It is like the container doens't notice the state change!
- user_info = CustomersStore.for(this).getAuth();
- return user_info;
- }
- },
- failed(errors) {
- console.log("failedddd", errors);
- }
- });
- //my customersStore
- var CustomersStore = Marty.createStore({
- id: 'CustomersStore',
- handlers: {
- isLogged: UserConstants.IS_LOGGED // ----> This is the method called when with the query in my component in getInitialState()
- },
- getInitialState: function () {
- CustomerQueries.isLogged(); // I am trying to call it even from here, and they both arrive to isLogged, because I see my state changing
- },
- isLogged: function (userData) { // if the resources of the response are null, is not logged
- if(userData.resources){
- this.setState({auth: 1});
- }else{
- this.setState({auth: 0});
- }
- },
- // It never arrive here!!!!! I don't know why!
- getAuth: function (){
- console.log("Now I am here!!!");
- return this.fetch({
- id: "logged-in",
- locally: function () {
- return this.state;
- },
- remotely: function () {
- return CustomerQueries.isLogged();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement