Exemplo n.º 1
0
//newTodo creates a new todo list item for a given string.  Note that the
//three primary elements are Attributes so the constraint system can operate
//on them.  The value provided is used to initialize the displayed text.
func newTodo(raw string) *todo {
	result := &todo{
		name:    s5.NewStringSimple(raw),
		done:    s5.NewBooleanSimple(false),
		editing: s5.NewBooleanSimple(false),
	}
	result.modName = s5.NewModelName(result)
	return result
}
Exemplo n.º 2
0
//newApp creates a new instance of the application object, properly
//initialized
func newApp() *todoApp {
	result := &todoApp{}
	//init the list, setting our own object as the joiner (we meet
	//the interface Joiner)
	result.todos = s5.NewList(result)

	//create initial values of attributes
	result.numNotDone = s5.NewIntegerSimple(0)
	result.plural = s5.NewStringSimple("")
	result.someDone = s5.NewBooleanSimple(false)
	result.numDone = s5.NewIntegerSimple(0)

	//done create app object
	return result
}