--[=[
	Uses the constructor to attach a class or resource to the actual object
	for the lifetime of the subscription of that object.
	@param constructor T
	@return (parent: Instance) -> Observable<T>
]=]

function Blend.Attached(constructor)
	return function(parent)
		return Observable.new(function(sub)
			local maid = Maid.new()

			local resource = constructor(parent)

			if MaidTaskUtils.isValidTask(resource) then
				maid:GiveTask(resource)
			end

			sub:Fire(resource)

			return maid
		end)
	end;
end
