<commit_before>//
//  StateStorage.swift
//  ADHOC_SignalGraph3
//
//  Created by <NAME>. on 2015/06/25.
//  Copyright (c) 2015 Eonil. All rights reserved.
//



public class StateStorage<T>: ChannelType {
	public typealias	Signal		=	StateSignal<T>
	
	public init(_ state: T) {
		self.state	=	state
	}
	deinit {
	}
	
	public var state: T {
		willSet {
			_castWillEnd()
		}
		didSet {
			_castDidBegin()
		}
	}
	
	public func register(identifier: ObjectIdentifier, handler: Signal->()) {
		_signch.register(identifier, handler: handler)
		_castDidBegin()
		
	}
	public func deregister(identifier: ObjectIdentifier) {
		_castWillEnd()
		_signch.deregister(identifier)
	}
	
	///
	
	private let	_signch		=	SignalChannel<Signal>()
	
	private func _castDidBegin() {
		_signch.cast(StateSignal<T>.DidBegin(state: { [weak self] in self!.state}))
	}
	private func _castWillEnd() {
		_signch.cast(StateSignal<T>.WillEnd(state: { [weak self] in self!.state}))
	}
}

///	Temporary for Swift 1.x.
///	Remove at Swift 2.x.
extension StateStorage {
	public var snapshot: T {
		get {
			return	state
		}
	}
}

<commit_msg>Added `public` to an extension.<commit_after>//
//  StateStorage.swift
//  ADHOC_SignalGraph3
//
//  Created by <NAME>. on 2015/06/25.
//  Copyright (c) 2015 Eonil. All rights reserved.
//



public class StateStorage<T>: ChannelType {
	public typealias	Signal		=	StateSignal<T>
	
	public init(_ state: T) {
		self.state	=	state
	}
	deinit {
	}
	
	public var state: T {
		willSet {
			_castWillEnd()
		}
		didSet {
			_castDidBegin()
		}
	}
	
	public func register(identifier: ObjectIdentifier, handler: Signal->()) {
		_signch.register(identifier, handler: handler)
		_castDidBegin()
		
	}
	public func deregister(identifier: ObjectIdentifier) {
		_castWillEnd()
		_signch.deregister(identifier)
	}
	
	///
	
	private let	_signch		=	SignalChannel<Signal>()
	
	private func _castDidBegin() {
		_signch.cast(StateSignal<T>.DidBegin(state: { [weak self] in self!.state}))
	}
	private func _castWillEnd() {
		_signch.cast(StateSignal<T>.WillEnd(state: { [weak self] in self!.state}))
	}
}

///	Temporary for Swift 1.x.
///	Remove at Swift 2.x.
public extension StateStorage {
	public var snapshot: T {
		get {
			return	state
		}
	}
}


{'fraction_non_alphanumeric': 0.13264850379633766, 'fraction_numerical': 0.013398838767306834, 'mean_word_length': 3.332688588007737, 'pattern_counts': {'":': 0, '<': 15, '<?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': '2062556', 'n_tokens_mistral': 906, 'n_tokens_neox': 794, 'n_words': 187}