-- Emits valid links in format Brio.new(link, linkValue)

function RxLinkUtils.observeValidLinksBrio(linkName, parent)
	assert(type(linkName) == "string", "linkName should be 'string'")
	assert(typeof(parent) == "Instance", "parent should be 'Instance'")

	return RxInstanceUtils.observeChildrenBrio(parent)
		:Pipe({
			Rx.flatMap(function(brio)
				local instance = brio:GetValue()
				if not instance:IsA("ObjectValue") then
					return Rx.EMPTY
				end

				return RxBrioUtils.completeOnDeath(brio, RxLinkUtils.observeValidityBrio(linkName, instance))
			end);
		})
end
