volt - Task not setting variables properly? -


having issues getting variable passed client. task gets run this:

def getmaps   $mapnames_current = []   url = 'http://s3-ap-northeast-1.amazonaws.com/splatoon-data.nintendo.net/stages_info.json'   resp = net::http.get_response(uri.parse(url))   buffer = resp.body   result = json.parse(buffer)   result.each |gamemode|     gamemode['stages'].each |stage|       $mapnames_current << $mapnames.key(stage['id'])     end   end end 

and $mapnames_current gets called here:

    <div class="text-center">       <h2>current maps!</h2>       <h3>turf war:</h3>       <h2>{{ $mapnames_current[0] }}</h2>       <h2>{{ $mapnames_current[1] }}</h2>       <h3>ranked:</h3>       <h2>{{ $mapnames_current[2] }}</h2>       <h2>{{ $mapnames_current[3] }}</h2>     </div> 

i'm not sure what's going wrong here. shouldn't $mapnames_current variable accessible everywhere?

global variables aren't synced between client , server. thing passed between client , server task return values of task. (which should can serialized json (or date types in json)).

there's screencast on tasks here: http://datamelon.io/blog/2015/creating-volt-task-objects.html


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -