bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 343 forks source link

Expose top of backstack API more cheaply #664

Closed ursusursus closed 1 year ago

ursusursus commented 2 years ago

Hey, I find my self peeking at the top of backstack often.

getBackstack().lastOrNull()?.controller

This however allocates the list unnecessarily

I used to be able to "hack" it by creating same package but now as Backstack moved to kotlin and it's internal, this no longer works (this.backstack.peek()?.controller)

It would complement the getBackstackSize well

PaulWoitaschek commented 1 year ago

Thanks for your suggestion!

It's just a list, so as long as you're not calling this in a loop a lot, this won't cause any measurable performance / memory impact. And usually this will not happen as calls to the backstack normally happen in reaction to a user event.