<commit_before>/* global window */
'use strict';

var _           = require('underscore');
var React       = require('react');
var dispatcher  = require('synapse-common/lib/dispatcher');

var ReactRouter = require('react-nested-router');
var Router      = ReactRouter.Router;
var Route       = ReactRouter.Route;

var TokenStore  = require('./store/token');
var UserStore   = require('./store/user');

var SiteLayout   = require('./ui/layouts/site');
var HomePage     = require('./ui/pages/home');
var LoginPage    = require('./ui/pages/login');
var NotFoundPage = require('./ui/pages/404');

function Application() {
    this.dispatcher = dispatcher;
    this.router     = Router;

    this.tokenStore = new TokenStore();
    this.userStore  = new UserStore(this.tokenStore);

    this.stores = {
        token : this.tokenStore,
        user  : this.userStore
    };
}

Application.prototype.start = function() {
    window.React = React;
    React.initializeTouchEvents(true);

    dispatcher.on('navigate', function() {
        Router.transitionTo.apply(Router, arguments);
    });

    dispatcher.on('token:update', _.bind(function(tokenData) {
        this.tokenStore.setToken(tokenData);
        this.userStore.fetch();
    }, this));<commit_msg>add dispatcher event<commit_after>/* global window */
'use strict';

var _           = require('underscore');
var React       = require('react');
var dispatcher  = require('synapse-common/lib/dispatcher');

var ReactRouter = require('react-nested-router');
var Router      = ReactRouter.Router;
var Route       = ReactRouter.Route;

var TokenStore  = require('./store/token');
var UserStore   = require('./store/user');

var SiteLayout   = require('./ui/layouts/site');
var HomePage     = require('./ui/pages/home');
var LoginPage    = require('./ui/pages/login');
var NotFoundPage = require('./ui/pages/404');

function Application() {
    this.dispatcher = dispatcher;
    this.router     = Router;

    this.tokenStore = new TokenStore();
    this.userStore  = new UserStore(this.tokenStore);

    this.stores = {
        token : this.tokenStore,
        user  : this.userStore
    };
}

Application.prototype.start = function() {
    window.React = React;
    React.initializeTouchEvents(true);

    dispatcher.on('navigate', function() {
        Router.transitionTo.apply(Router, arguments);
    });

    dispatcher.on('forward', function(route, params) {
        ReactRouter.replaceWith(route, params || {});
    });

    dispatcher.on('token:update', _.bind(function(tokenData) {
        this.tokenStore.setToken(tokenData);
        this.userStore.fetch();
    }, this));
{'fraction_non_alphanumeric': 0.1524135309768149, 'fraction_numerical': 0.002280501710376283, 'mean_word_length': 3.197767145135566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '744931', 'n_tokens_mistral': 780, 'n_tokens_neox': 767, 'n_words': 148}