Sub class_globals
private data As BANanoObject
private methods As Map
private vm As BANanoObject
End Sub
Sub Serve
Dim beforeMountCB As BANanoObject = BANano.CallBack(me, "beforeMount", null)
Dim dataCB As BANanoObject = BANano.CallBack(me, "returndata", null)
Dim options As Map = CreateMap()
options.put("el", "#vm")
options.put("template", $"<div>{{ item.count }}<input type="button" value="Click" @click="updateCount"/></div>"$)
options.put("data", dataCB)
options.put("beforeMount", beforeMountCB)
options.put("methods", methods)
vm.Initialize2("Vue", options)
dim vdata As String = "$data"
data = vm.getfield(vdat)
End Sub
Sub returndata As BANanoObject
return data
End Sub
Sub SetData(prop As String, value As Object)
data.setfield(prop, value)
End Sub
Sub GetData(prop As String) As Object
dim res as Object = data.getfield(prop)
return res
End Sub
Sub AddMethod(methodName As String)
dim args As List
args.Initialize
dim cb As BANanoObject = BANano.CallBack(me, methodName, BANano.Spread(args))
methods.put(methodname, cb)
End Sub
Usage...
[code]
Sub Init
AddMethod("updateCount")
Serve
End Sub
Sub updateCount
dim item As Map = GetData("item")
dim count As int = item.get("count")
count = BANano.parseInt(count) + 1
item.put("count", count)
SetData("item", item)
End Sub
Sub beforeMount
dim item As Map = CreateMap()
item.put("count", 0)
SetData("item", item)
End Sub