mindorksopensource / kotlin-flow-android-examples Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Would a PagedList implementation using Flow be possible?
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7087)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1085)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:4829)
at android.view.View.invalidateInternal(View.java:11990)
at android.view.View.invalidate(View.java:11950)
at android.view.View.invalidate(View.java:11934)
at android.widget.TextView.checkForRelayout(TextView.java:7170)
at android.widget.TextView.setText(TextView.java:4114)
at android.widget.TextView.setText(TextView.java:3966)
at android.widget.TextView.setText(TextView.java:3941)
at com.mindorks.kotlinFlow.learn.search.SearchActivity$setUpSearchStateFlow$1$invokeSuspend$$inlined$filter$1$2.emit(Collect.kt:137)
at kotlinx.coroutines.flow.FlowKt__DelayKt$debounce$2$invokeSuspend$$inlined$select$lambda$2.invokeSuspend(Delay.kt:66)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Hi, first, thanks for creating these examples. I have a few questions:
So, as we know, Flow is used for returning multiple asynchronously computed values. But here we are only doing a single task and returning a single value. Wouldn't it be more appropriate to use suspend function along with withContext { } instead of Flow for a single long running task?
I was wondering why have you used Flow? Does it offer any adavantage over withContext { } in this case?
In case, this example is only for demonstration purposes? Don't we need a more suitable example?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.