Comments (3)
I had a similar problem or, rather, the same exception in a slightly different scenario.
I had a screen showing a detail about an item which could optionally open a screen to show the detail about a "related" item.
These were two different instances of the same Screen subclass. Without transitions everything worked fine, when adding transitions opening the related screen crashed with the transition was used multiple times
error.
Solution: overriding the key property and return a custom unique key, in my case concatenating the item ID was enough since in my context the relation is not reflexive so no two instances of the same screen with the same ID can ever be adjacent.
PS: If the navigation is A -> B -> A (the relation is symmetric) no issue and no crash whatsoever.
from voyager.
For now, I just ended up doing my own debouncing click operator in my compose
private const val DEBOUNCE_TIME_MILLIS = 1000L
internal interface EventProcessor {
fun processEvent(event: () -> Unit)
companion object {
val buttonClickMap = mutableMapOf<String, EventProcessor>()
}
}
internal fun EventProcessor.Companion.get(id: String): EventProcessor {
return buttonClickMap.getOrPut(
id
) {
EventProcessorImpl()
}
}
private class EventProcessorImpl : EventProcessor {
private val now: Long
get() = Clock.System.now().toEpochMilliseconds()
private var lastEventTimeMs: Long = 0
override fun processEvent(event: () -> Unit) {
if (now - lastEventTimeMs >= DEBOUNCE_TIME_MILLIS) {
event.invoke()
}
lastEventTimeMs = now
}
}
@Composable
fun debouncedClick(
id: String = randomUUID(),
onClick: () -> Unit,
): () -> Unit {
val multipleEventsCutter = remember { EventProcessor.get(id) }
val newOnClick: () -> Unit = {
multipleEventsCutter.processEvent { onClick() }
}
return newOnClick
}
Usage:
Button(
onClick = debouncedClick {
// clicked
},
) {
Text("Button")
}
from voyager.
I ran into this while trying to nest a TabNavigator
into a Navigator
funnily enough.
from voyager.
Related Issues (20)
- Popping navigator in background doesn't work
- navigator.pop() followed by navigator.push(screen) does not dispose the ScreenModel from the popped screen HOT 8
- Crash on Android because ScreenTransition do not inherit from Serializable HOT 5
- Double Navigation Bar Issue. HOT 1
- Can't pass the Dynamic Data using Tab Navigator
- iOS swipe to close does not work HOT 1
- Koin ScreenModel inject crash starting from 1.1.0-alpha04 HOT 1
- Screen transition broken in 1.1.0-beta02
- Can't pop root in Compose for Desktop
- [Desktop] Density is not updated on changing the window to a screen with different density
- [KMP ViewModels][Voyager][Koin] Crush if you try to navigate back
- Override the back press in each Screen in Compose Multiplatform HOT 3
- Snackbar overlapped by BottomSheet when using BottomSheetNavigator
- HorizontalPager HOT 1
- [WASM] [Font] tofu are displayed instead of the actual font HOT 1
- Android Activity Lifecycle events stop being forwarded by AndroidScreenLifecycleOwner after screen rotation
- BottomSheetNavigator - IOS Build error HOT 4
- Navigation testing
- Problem with @Transient during Screen serialization
- 最新版本打包ios 会报错
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 voyager.