+///	A reference wrapper around a mutable value. An object can subscribe for
+///	updates to this value with a function, which will have both the states of
+///	the transition as arguments. It's not mandatory to unsubscribe to the
+///	updates as no strong reference is kept and if a subscribed object gets
+///	deallocated it automatically gets unsubsribed.
+///
+///	- warning: The observer doesn't listen to the wrapped value changes, so if
+///		`Observed` is a reference type notifications of its update will be given
+///		only when the reference gets updated, and not when the referenced value
+///		does.
+///	- seealso:
+///		[Observer Pattern](https://en.wikipedia.org/wiki/Observer_pattern)
 public final class Observable<Observed> {
 	// MARK: - Private implementation
 	

}

extension Observable {
	public func map <T> (_ transform: @escaping (Observed) -> T) -> Observable<T> {
		let mappedObservable = Observable<T>(transform(value))
		subscribe(mappedObservable, onUpdate: { [weak mappedObservable] oldValue, newValue in
			mappedObservable?.value = transform(newValue)


	// MARK: - Public interface

	///	The type of the function that gets called back on updates.
	///	- note: `from` and `to` are not necessarily different. Use
	///		`subscribe(_:onChange:)` if you want to ensure that.
	///
	///	- parameter from: The wrapped value before the update.
	///	- parameter to: The wrapped value after the update.
	public typealias UpdateAction = (_ from: Observed, _ to: Observed) -> Void

	///	The wrapped value of which updates are tracked by the `Observable`
	///	object and notified to its observers. Can be read and changed by
	///	anyone.
    public var value: Observed {
        didSet { notifyObservers(from: oldValue, to: value) }
    }

	///	Create a new `Observable` wrapping the given `value`.
	///
	///	- parameter value: The initial value from which changes will be
	///		observed.
    public init(_ value: Observed) {
        self.value = value
    }

	///	Subscribe to updates on the wrapped value by calling the passed function
	///	every time that happens. The subscription is referenced to through the
	///	given object, which is not strongly referenced, so that needs to stay
	///	alive for the subscription to continue and must be used to unsubscribe.
	///	- note: `onUpdate` will be called whenever the wrapped value gets set,
	///		even if the value didn't change. It doesn't get called when you
	///		subscribe to it.
	///	- warning: Only one subscription per object per `Observable` is allowed.
	///		Subscribing again with the same object for updates will
	///		automatically remove the previous subscription. If you want to
	///		subscribe with separate callbacks from the same context, use two
	///		different objects for them.
	///	- seealso: `subscribe(_:onChange:)`
	///
	///	- parameter observer: The object that owns the subscription. It can be
	///		hold only one subscription per `Observable`. If this gets
	///		deallocated then it is automatically unsubscribed.
	///	- parameter onUpdate: The function that will get called on every update
	///		of the wrapped value.
	public func subscribe(_ observer: AnyObject, onUpdate: @escaping UpdateAction) {
		let identifier = ObjectIdentifier(observer)
		let autoreleasingOnUpdate: UpdateAction = { [weak self, weak observer] oldValue, newValue in
