<commit_before>import {Component} from 'angular2/core';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common';
import {ObjectDisplay} from '../objectDisplay/ObjectDisplay';
import {IGithubUser} from '../../services/ServiceInterfaces';
import {GithubServices} from '../../services/GithubServices';
import {GithubUser} from '../../models/GithubUser';
import {Http} from 'angular2/http';
import {Subject} from 'rxjs/Subject';
// import 'rxjs/add/operators/map';
// import 'rxjs/add/observable/interval';
// import 'rxjs/add/operators/where';

@Component({
    selector: 'mashup',
    providers: [GithubServices],
    templateUrl: './components/mashup/Mashup.html',
    directives: [CORE_DIRECTIVES, ObjectDisplay, FORM_DIRECTIVES]
})
export class Mashup {

    http:Http;
    userInfo: IGithubUser;
    nameUpdate: Subject<any>;
    userDisplayData: any;
    reposDisplayData: any;
    minNameLength: number = 8;
    currentNameLength: number = 0;

    constructor(http:Http, public githubServices:GithubServices) {
        this.http = http;
        this.userInfo = new GithubUser();
        this.userDisplayData = {
            name: 'Howard',
            address: {
                city: 'Plainview',
                state: 'New York'
            },
            sports: ['lacrosse', 'bowling',
                { name: 'football',
                  rank: 1,
                  players: [
                        'Randy',
                        { FirstName: 'Howard',
                          LastName: 'Pinsley',
                          Skills: ['Quarterback', 'WideReceiver', { Position: 'Running Back', Level: 'Expert'}]
                        },
                        'David'
                    ]
                  },
                'Tetherball'
            ]
        };
        this.reposDisplayData = {};
        this.setNameLookup();
    }

    setNameLookup() {
        this.nameUpdate = new Subject();

        this.nameUpdate.subscribe(name => this.currentNameLength = name ? name.length : 0);

        var lookupNamePub = this.nameUpdate
            .filter(name => name.length >= this.minNameLength);

        var namePub = lookupNamePub
            .mergeMap(name => this.githubServices.getUser(name));

        lookupNamePub.subscribe(name => console.log(`Lookup name observable returned name [${name}]`));

        namePub.subscribe(this.setUser.bind(this),
            error => console.log('Error', error));<commit_msg>Use object display to display the redux state<commit_after>import {Component} from 'angular2/core';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common';
import {ObjectDisplay} from '../objectDisplay/ObjectDisplay';
import {IGithubUser} from '../../services/ServiceInterfaces';
import {GithubServices} from '../../services/GithubServices';
import {GithubUser} from '../../models/GithubUser';
import {Http} from 'angular2/http';
import {Subject} from 'rxjs/Subject';
import {DataService} from '../../services/redux/DataService';

// import 'rxjs/add/operators/map';
// import 'rxjs/add/observable/interval';
// import 'rxjs/add/operators/where';

@Component({
    selector: 'mashup',
    providers: [GithubServices],
    templateUrl: './components/mashup/Mashup.html',
    directives: [CORE_DIRECTIVES, ObjectDisplay, FORM_DIRECTIVES]
})
export class Mashup {

    http:Http;
    userInfo: IGithubUser;
    nameUpdate: Subject<any>;
    userDisplayData: any;
    reposDisplayData: any;
    minNameLength: number = 8;
    currentNameLength: number = 0;

    constructor(http:Http,
                public dataService:DataService,
                public githubServices:GithubServices) {
        this.http = http;
        this.userInfo = new GithubUser();
        this.userDisplayData = {
            name: 'Howard',
            address: {
                city: 'Plainview',
                state: 'New York'
            },
            sports: ['lacrosse', 'bowling',
                { name: 'football',
                  rank: 1,
                  players: [
                        'Randy',
                        { FirstName: 'Howard',
                          LastName: 'Pinsley',
                          Skills: ['Quarterback', 'WideReceiver', { Position: 'Running Back', Level: 'Expert'}]
                        },
                        'David'
                    ]
                  },
                'Tetherball'
            ]
        };
        this.reposDisplayData = {};
        this.setNameLookup();
    }

    ngOnInit() {
        this.userDisplayData = this.dataService.getState();
    }

    setNameLookup() {
        this.nameUpdate = new Subject();

        this.nameUpdate.subscribe(name => this.currentNameLength = name ? name.length : 0);

        var lookupNamePub = this.nameUpdate
            .filter(name => name.length >= this.minNameLength);

        var namePub = lookupNamePub
            .mergeMap(name => this.githubServices.getUser(name));

        lookupNamePub.subscribe(name => console.log(`Lookup name observable returned name [${name}]`));

        namePub.subscribe(this.setUser.bind(this),
            error => console.log('Error', error));
{'fraction_non_alphanumeric': 0.1294460641399417, 'fraction_numerical': 0.0027210884353741495, 'mean_word_length': 2.08328340323547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '4204149', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1401, 'n_words': 297}