<commit_before>import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';

@Injectable()
export class Store implements OnInit {

	state;
	listeners = [];
	stateHistory = []; //holds previous states in the form of a stack
	listenerHistory = [];

	reducer(state: Object, action: Object) {

	}

	constructor() { }

	ngOnInit(): void {
		this.state = this.reducer(null, {})
	}

	getState() {
		return this.state
	}
	/*
	  * Takes in an action, which is a string (name of action), that gets passed into the reducer
	 */
	dispatch(action: Object) {
		if (this.state) this.stateHistory.push(this.state);
		this.state = this.reducer(this.state, action.type);
		this.listeners.forEach(l => l()) //loop through the array of listeners
	}

	subscribe(fn) {
		this.listenerHistory.push(this.listeners);
		this.listeners = this.listeners.concat(fn); // not altering the original listeners array.
		return () => this.listeners.filter(func => func !== fn)
	}

}
<commit_msg>Comments added / more tuning<commit_after>import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';

// Only GETSTATE, DISPATCH, and SUBSCRIBE should be invoked from outside this component

@Injectable()
export class Store implements OnInit {

	private state;
	private listeners = [];
	private stateHistory = []; //holds previous states in the form of a stack
	private listenerHistory = [];

	private reducer(state: Object, action: Object) {
		let newState;
		// Add functionality for initiation and updating of state here.
		// After initialization, do NOT modify this.state. Modify newState and return that instead.
		// Previous version of this.state will be saved in this.stateHistory by the dispatch method.

		return newState;
	}

	private constructor() { }

	private ngOnInit(): void { this.state = this.reducer(null, {}) }

	getState() { return this.state }

	dispatch(action: Object) {
		this.stateHistory.push(this.state);
		this.state = this.reducer(this.state, action.type);
		this.listeners.forEach(l => l()) //loop through the array of listeners
	}

	subscribe(fn) {
		this.listenerHistory.push(this.listeners);
		this.listeners = this.listeners.concat(fn); // not altering the original listeners array.
		return () => {
			this.listenerHistory.push(this.listeners);
			this.listeners = this.listeners.filter(func => func !== fn);
		}
	}
}

{'fraction_non_alphanumeric': 0.12746331236897274, 'fraction_numerical': 0.0, 'mean_word_length': 4.0020964360587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6400514', 'n_tokens_mistral': 757, 'n_tokens_neox': 713, 'n_words': 217}