Comments (8)
from android-ktx.
from android-ktx.
Yeah we used to have something like this until we switched to operator fun iterator()
. It's a shame there isn't a structural typing such that all the existing collection extensions could apply. Is there any reason to expose a List
rather than an Iterable
?
from android-ktx.
Honestly no, I agree that Iterable
seems more appropriate. Will change the title of the issue
from android-ktx.
Any thoughts on it being a Sequence
instead? This is what we implemented in our project, I'm not sure if the laziness of a sequence is more or less desirable though.
/**
* Returns a [Sequence] that iterates through the children of this view
*/
val ViewGroup.children: Sequence<View>
get() {
var currentIndex = -1
return generateSequence {
currentIndex++
getChildAt(currentIndex)
}
}
from android-ktx.
IMHO it should always return a Iterable
. If you need it as a sequence you could always do myView.children.asSequence()
.
from android-ktx.
It seems equally simple, as Jake said, to convert between Iterable
and Sequence
. I personally like how, if you provide it as a Sequence
, doing something like children.filterIsInstance<FooView>().map { it.foo() }.first()
is lazily evaluated by default, without having to remember to convert it to a Sequence
first.
from android-ktx.
Was merged.
from android-ktx.
Related Issues (20)
- Convenience DSL for Media Controller Callback event handling
- androidx.preference.PreferenceFragment not derived from androidx.fragment.app.Fragment HOT 2
- Manifest merger failed HOT 5
- Release of 1.0.0-alpha3 out of sync with this repo HOT 4
- Extension property of bitmap from ImageView HOT 1
- error: resource android:attr/fontVariationSettings not found. HOT 1
- ImageDecoder source and test issues HOT 7
- inline extension properties can't be used in SAM lambda functions due to compiler bug HOT 1
- Add popular libraries extensions in new module HOT 1
- AAPT2 Error HOT 1
- View.post with with this view as a parameter HOT 2
- Resources.Theme.resolveAttribute extension
- Improve View.doOnPreDraw(...) HOT 1
- Features suggestions: Live data transformation HOT 1
- Offer: AsyncTask replacement
- Can't use getString(String) : String HOT 2
- androidx.core.os.BundleKt.bundleOf: Imports for API 21 classes break on older devices HOT 2
- gradle error HOT 3
- Add support for manipulating a color as HSV HOT 1
- Hi everyone!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-ktx.