Comments (1)
Hi @mikef-dk,
thank you for your thoughts ragarding performance improvements.
StateEvent
and StateEventWithContent
are both composable functions. The annotation @Immutable
is targeting classes only. So composables can't be marked as immutable this way. The compose compiler consideres a composable to be skippable
if all passed parameters are immutable and did not change.
I went ahead and marked StateEvent
and StateEventWithContent
explicitly as immutable
. Furthermore I found the @NonRestartableComposable
annotiation which seems fitting for all the event side effect.
After these 2 optimisations, the third parameter action: suspend (T) -> Unit
is the only one that stays unstable
.
I think this is pretty much all the library can optimize at this point.
When using the event side effects, one could try remembering the action
lambda according to this article. If this prevents recompositions strongly depends on the individual implementations of your action
lambda(s).
Compose compiler reports:
stable class Triggered {
}
stable class Consumed {
}
stable class StateEventWithContentTriggered {
runtime val content: T
}
stable class StateEventWithContentConsumed {
}
fun EventEffect(
stable event: StateEvent
stable onConsumed: Function0<Unit>
unstable action: SuspendFunction0<Unit>
)
fun EventEffect(
stable event: StateEventWithContent<T>
stable onConsumed: Function0<Unit>
unstable action: SuspendFunction1<T, Unit>
)
fun NavigationEventEffect(
stable event: StateEvent
stable onConsumed: Function0<Unit>
unstable action: SuspendFunction0<Unit>
)
fun NavigationEventEffect(
stable event: StateEventWithContent<T>
stable onConsumed: Function0<Unit>
unstable action: SuspendFunction1<T, Unit>
)
from compose-state-events.
Related Issues (5)
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 compose-state-events.