--[=[
	Flattens all the brios in one brio and combines them, and then switches it to
	a brio so only the last state is valid.

	@param observables { [any]: Observable<Brio<T>> | Observable<T> | T }
	@param filter function | nil
	@return Observable<Brio<{ [any]: T }>>
]=]

function RxBrioUtils.flatCombineLatestBrio(observables, filter)
	assert(type(observables) == "table", "Bad observables")

	return RxBrioUtils.flatCombineLatest(observables)
		:Pipe({
			RxBrioUtils.switchToBrio();
			filter and RxBrioUtils.where(filter) or nil
		})
end
