Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. // my component
  2.  
  3. var App = React.createClass({
  4. getInitialState: function() {
  5. CustomerQueries.isLogged();
  6. return {};
  7. },
  8. render () {
  9. //here my markup
  10. }
  11. });
  12.  
  13. // my cointainer
  14. App = Marty.createContainer(App ,{
  15. listenTo: CustomersStore,
  16. fetch: {
  17. auth: function () {
  18. console.log("I am here!!!!"); // ---->>> it doesn't arrive here! It is like the container doens't notice the state change!
  19. user_info = CustomersStore.for(this).getAuth();
  20. return user_info;
  21. }
  22. },
  23. failed(errors) {
  24. console.log("failedddd", errors);
  25. }
  26. });
  27.  
  28.  
  29.  
  30. //my customersStore
  31.  
  32. var CustomersStore = Marty.createStore({
  33. id: 'CustomersStore',
  34. handlers: {
  35.  
  36. isLogged: UserConstants.IS_LOGGED // ----> This is the method called when with the query in my component in getInitialState()
  37. },
  38. getInitialState: function () {
  39. CustomerQueries.isLogged(); // I am trying to call it even from here, and they both arrive to isLogged, because I see my state changing
  40. },
  41. isLogged: function (userData) { // if the resources of the response are null, is not logged
  42.  
  43. if(userData.resources){
  44. this.setState({auth: 1});
  45. }else{
  46. this.setState({auth: 0});
  47. }
  48. },
  49. // It never arrive here!!!!! I don't know why!
  50. getAuth: function (){
  51. console.log("Now I am here!!!");
  52. return this.fetch({
  53. id: "logged-in",
  54. locally: function () {
  55. return this.state;
  56. },
  57. remotely: function () {
  58. return CustomerQueries.isLogged();
  59. }
  60. });
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement