원시값을 가지는 플로우

flowOf() 함수

suspend fun main() {
		flowOf(1, 2, 3, 4, 5)
				.collect { print(it) } // 12345
}

emptyFlow() 함수

suspend fun main() {
		emptyFlow<Int>()
				.collect { print(it) } // 아무것도 출력되지 않음
}

컨버터

asFlow() 함수

suspend fun main() {
    listOf(1, 2, 3, 4, 5)
        // 또는 setOf(1, 2, 3, 4, 5)
        // 또는 sequenceOf(1, 2, 3, 4, 5)
        .asFlow()
        .collect { print(it) } // 12345

suspend 함수를 Flow로 변환

suspend fun main() {
    val function = suspend {
        delay(1000)
        "UserName"
    }

    function.asFlow() // 이렇게 변환 가능!
        .collect { print(it) }
}

// (1초 후)
// UserName