function Blend.mount(R,N)local p=Maid.new()local t=nil local C={}for N,X in pairs(N)do if type(N)=="\115\116\114\105\110\103"then if N=="\080\097\114\101\110\116"then t=X else local t=Blend.toPropertyObservable(X)if t then p:GiveTask(t:Subscribe(function(p)task.spawn(function()R[N]=p end)end))else task.spawn(function()R[N]=X end)end end elseif type(N)=="\102\117\110\099\116\105\111\110"then local p=Blend.toEventObservable(N(R,X))if Observable.isObservable(p)then table.insert(C,{p;X})else warn(("\085\110\097\098\108\101 \116\111 \097\112\112\108\121 \101\118\101\110\116 \108\105\115\116\101\110\101\114 \037\113"):format(tostring(N)))end else warn(("\085\110\097\098\108\101 \116\111 \097\112\112\108\121 \112\114\111\112\101\114\116\121 \037\113"):format(tostring(N)))end end for R,N in pairs(C)do p:GiveTask(N[1]:Subscribe(Blend.toEventHandler(N[2])))end if t then local N=Blend.toPropertyObservable(t)if N then p:GiveTask(N:Subscribe(function(N)R.Parent=N end))else R.Parent=t end end return p end return Blend
--[=[
	Mounts the instance to the props. This handles mounting children, and events.

	The contract is that the props table is turned into observables. Note the following.

	* Keys of strings are turned into properties
		* If this can be turned into an observable, it will be used to subscribe to this event
		* Otherwise, we assign directly
	* Keys of functions are invoked on the instance in question
		* `(instance, value) -> Observable
		* If this returns an observable (or can be turned into one), we subscribe the event immediately
	* If the key is [Blend.Children] then we invoke mountChildren on it

	@param instance Instance
	@param props table
	@return Maid
]=]
function Blend.mount(instance, props)
	local maid = Maid.new()

	local parent = nil
	local dependentObservables = {}

	for key, value in pairs(props) do
		if type(key) == "string" then
			if key == "Parent" then
				parent = value
			else
				local observable = Blend.toPropertyObservable(value)
				if observable then
					maid:GiveTask(observable:Subscribe(function(result)
						task.spawn(function()
							instance[key] = result
						end)
					end))
				else
					task.spawn(function()
						instance[key] = value
					end)
				end
			end
		elseif type(key) == "function" then
			local observable = Blend.toEventObservable(key(instance, value))

			if Observable.isObservable(observable) then
				table.insert(dependentObservables, { observable, value })
			else
				warn(("Unable to apply event listener %q"):format(tostring(key)))
			end
		else
			warn(("Unable to apply property %q"):format(tostring(key)))
		end
	end

	-- Subscribe dependentObservables (which includes adding children)
	for _, event in pairs(dependentObservables) do
		maid:GiveTask(event[1]:Subscribe(Blend.toEventHandler(event[2])))
	end

	if parent then
		local observable = Blend.toPropertyObservable(parent)
		if observable then
			maid:GiveTask(observable:Subscribe(function(result)
				instance.Parent = result
			end))
		else
			instance.Parent = parent
		end
	end

	return maid
end

return Blend
