コード例 #1
0
// NewValueSelectionNodeTexter returns a new instance of ValueSelectionNodeTexter.
func NewValueSelectionNodeTexter(node *viewmodel.ValueSelectionNode, listener ViewModelListener) *ValueSelectionNodeTexter {
	texter := &ValueSelectionNodeTexter{
		listener:        listener,
		node:            node,
		onDetailChanged: NullDetailChangeCallback}

	node.Selected().Subscribe(func(string) {
		texter.onSelectedChanged()
	})
	node.Subscribe(func([]string) {
		texter.onDetailChanged()
	})

	return texter
}
コード例 #2
0
func (filler *viewModelFiller) ValueSelection(node *viewmodel.ValueSelectionNode) {
	filler.object = js.Global.Get("Object").New()
	filler.object.Set("type", "valueSelection")
	filler.object.Set("label", node.Label())
	{
		selectedFiller := newViewModelFiller()
		node.Selected().Specialize(selectedFiller)
		filler.object.Set("selected", selectedFiller.object)
	}
	{
		observable := ko.NewObservableArray(node.Values())

		filler.object.Set("values", observable.ToJS())
		node.Subscribe(func(newValues []string) {
			observable.Set(newValues)
		})
	}
}