<commit_before>define([
    'fossil/module',
    'fossil/viewStore',
    'fossil/views/view',
    './todo',
    './todoCollection',
    './listView',
    './showView'
], function (Module, ViewStore, View, Todo, TodoCollection, ListView, ShowView) {
    var Application = Module.extend({

        events: {
            'start': 'startListener',
            'standby': 'standbyListener'
        },

        startListener: function (app) {

            var store = this.store = new ViewStore();
            store.set('404', function (message) {
                return new View({template: message || 'Not found'});
            });
            store.set('loading', function () {
                return new View({
                    template: '<p>Loading...</p>'
                });
            });
            store.set('list', function (collection) {
                return new ListView({
                    collection: collection,
                    // reuse the view
                    recycle: true
                });
            });
            store.set('show', function (collection, id) {
                return new ShowView({
                    model: collection.get(id)
                });
            });

            // initialize collection.
            var todos = this.todos = new TodoCollection();

            this
                // set view while loading.
                //
                // When `useView` receives a string, it is used as template.
                .useView('Loading')
                // event processing can delay next execution until
                // a set of promises are resolved.
                //
                // So wait until all Todos are retreived from remote store.
                .waitFor(todos.fetch())
                // if an error occurs, 'Error' will be displayed.
                .thenUseView(null, 'Error');
        },

        standbyListener: function (app) {
            // unbind any remaining event on todos collection.
            this.todos.stopListening();
            // and delete it.
            this.todos = null;

            this.store.clean();
            this.store = null;
        },


        routes: {
            '': 'index',
            ':id': 'show'
        },

        index: function () {
            var view = new ListView({
                collection: this.todos
            });

            this.useView(view);
        },

        show: function (id) {
            var todo = this.todos.get(id);
<commit_msg>Make usage ov view store in todo sample.<commit_after>define([
    'fossil/module',
    'fossil/viewStore',
    'fossil/views/view',
    './todo',
    './todoCollection',
    './listView',
    './showView'
], function (Module, ViewStore, View, Todo, TodoCollection, ListView, ShowView) {
    "use strict";
    var Application = Module.extend({

        events: {
            'start': 'startListener',
            'standby': 'standbyListener'
        },

        startListener: function (app) {

            var store = this.store = new ViewStore();
            store.set('404', function (message) {
                return new View({template: message || 'Not found'});
            });
            store.set('loading', function () {
                return new View({
                    template: '<p>Loading...</p>'
                });
            });
            store.set('list', function (collection) {
                return new ListView({
                    collection: collection,
                    // reuse the view
                    recycle: true
                });
            });
            store.set('show', function (collection, id) {
                return new ShowView({
                    model: collection.get(id)
                });
            });

            // initialize collection.
            var todos = this.todos = new TodoCollection();

            this
                // set view while loading.
                //
                // When `useView` receives a string, it is used as template.
                .useView('Loading')
                // event processing can delay next execution until
                // a set of promises are resolved.
                //
                // So wait until all Todos are retreived from remote store.
                .waitFor(todos.fetch())
                // if an error occurs, 'Error' will be displayed.
                .thenUseView(null, 'Error');
        },

        standbyListener: function (app) {
            // unbind any remaining event on todos collection.
            this.todos.stopListening();
            // and delete it.
            this.todos = null;

            this.store.clean();
            this.store = null;
        },


        routes: {
            '': 'index',
            ':id': 'show'
        },

        index: function () {
            this.useView(this.store.get('list', this.todos));
        },

        show: function (id) {
            var todo = this.todos.get(id);

{'fraction_non_alphanumeric': 0.11930106447077726, 'fraction_numerical': 0.0012050612572805785, 'mean_word_length': 1.2281879194630871, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7368121', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1220, 'n_words': 334}