const Observable = require('data/observable').Observable;
const taskList = require('../../shared/view-models/task-list-view-model');
const frameModule = require("ui/frame");

let pageData = new Observable({
    task: ''
});

function pageLoaded(args) { 
    pageData.task = '';
    var page = args.object;
    page.bindingContext = pageData;
}

function save() {
    taskList.add(pageData.task);
    const topmost = frameModule.topmost();
    topmost.navigate("views/list/list");
}

module.exports = {
    pageLoaded,
    save
}