i have small reactjs application in flux architecture. need fetch server side data in each button click. write code in store these
var piedataformembers=[]; var reportstore = assign({}, eventemitter.prototype, { reportmemberlist : function(reportmemberdetails){ ob.projectmember(reportmember,function(getmemberseffort){ //ajax call piedataformembers = getmemberseffort; }); return piedataformembers; }}
but when run code not waiting server data , return null value.
your return statement return before ob.projectmember
runs callback. how javascript works. execute end of block (returning value null @ time) , make call ob.projectmember
, time later run response callback.
you should take return statement out, not serving purpose. action need server result should done in anonymous function pass in ob.projectmember
callback.
if following flux method should make api call action , response server in action should send result dispatcher send store.
if want keep going way have done above (ie making server/api call store) need store tell component. done emitting event havent put such code in question. doing believe not correct way.
Comments
Post a Comment