/// <reference path='../typings/jquery/jquery.d.ts' />
/// <reference path="../typings/knockout/knockout.d.ts" />
/// <reference path="../typings/custom/head.load.d.ts" />
/// <reference path="../../../packages/knockout_view/js/Tops.App/App.ts" />
/// <reference path="../../../packages/knockout_view/js/Tops.Peanut/Peanut.ts" />
/// <reference path="../../../packages/knockout_view/js/Tops.Peanut/Peanut.d.ts" />
module Tops {
    export class VmNameViewModel implements IMainViewModel {
        static instance: Tops.VmNameViewModel;
        private application: Tops.IPeanutClient;
        private peanut: Tops.Peanut;

        // observable declarations here

        // Constructor
        constructor() {
            var me = this;
            Tops.VmNameViewModel.instance = me;
            me.application = new Tops.Application(me);
            me.peanut = me.application.peanut;
        }

        /**
         * @param successFunction - page inittializations such as ko.applyBindings() go here.
         *
         * Call this function in a script at the end of the page following the closing "body" tag.
         * e.g.
         *      ViewModel.init(function() {
         *          ko.applyBindings(ViewModel);
         *      });
         *
         */
        init(successFunction?: () => void) {
            var me = this;
            // setup messaging and other application initializations
            me.application.initialize(
                function() {
                    // do view model initializations here.
                    successFunction();

                }
            );
        }
    }
}

Tops.VmNameViewModel.instance = new Tops.VmNameViewModel();
(<any>window).VmNameViewModel = Tops.VmNameViewModel.instance;
