Jetpack Compose internals
Minimum price
Suggested price

Jetpack Compose internals

About the Book

This book explores the guts of Jetpack Compose, the brand new library by Google and the Android team that will become the future of Android UI. Dedicating time now to learn about its internals in-depth will yield powerful skills to write modern and efficient Android apps in the future.

If you are interested in other use cases of Jetpack Compose rather than Android, this book has got you covered also. Jetpack Compose internals is very focused on exploring the compiler and runtime from a generic perspective, making the overall experience very agnostic of the target platform. The book also provides a chapter dedicated to diverse use cases for Jetpack Compose, which exposes a few really interesting examples over code.

Jetpack Compose and Android are trademarks of Google LLC and this book is not endorsed by or affiliated with Google in any way.

  • Share this book

  • Categories

    • Software
    • Computers and Programming
    • Java
    • Kotlin
    • Software Architecture
    • Software Engineering
  • Feedback

    Email the Author(s)


About the Author

Jorge Castillo
Jorge Castillo

Jorge is a Google Developer Expert (GDE) for Android and Kotlin that has been traditionally very active in the Android community.

Bundles that include this book

Bought separately
Minimum price
Suggested price

About the Contributors

Andrei Shikov
Andrei Shikov

Software Engineer

Andrei wrote the chapter about "Advanced Compose runtime use cases", one of the most interesting chapters in the book. It showcases how to create client libraries that leverage all the power of the Compose runtime.

Table of Contents

  • Prelude
    • Why to read this book
    • What this book is not about
    • Why to write about internals
    • Keep the sources close
    • Code snippets and examples
  • 1. Composable functions
    • The meaning of Composable functions
    • Properties of Composable functions
    • Calling context
    • Idempotent
    • Free of uncontrolled side effects
    • Restartable
    • Fast execution
    • Positional memoization
    • Similarities with suspend functions
    • The color of Composable functions
    • Composable function types
  • 2. The Compose compiler
    • A Kotlin compiler plugin
    • Compose annotations
    • Registering Compiler extensions
    • Kotlin Compiler version
    • Static analysis
    • Static Checkers
    • Call checks
    • Type checks
    • Declaration checks
    • Diagnostic suppression
    • Runtime version check
    • Code generation
    • The Kotlin IR
    • Lowering
    • Inferring class stability
    • Enabling live literals
    • Compose lambda memoization
    • Injecting the Composer
    • Comparison propagation
    • Default parameters
    • Control flow group generation
    • Klib and decoy generation
  • 3. The Compose runtime
    • The slot table and the list of changes
    • The slot table in depth
    • The list of changes
    • The Composer
    • Feeding the Composer
    • Modeling the Changes
    • Optimizing when to write
    • Writing and reading groups
    • Remembering values
    • Recompose scopes
    • SideEffects in the Composer
    • Storing CompositionLocals
    • Storing source information
    • Linking Compositions via CompositionContext
    • Accessing the current State snapshot
    • Navigating the nodes
    • Keeping reader and writer in sync
    • Applying the changes
    • Performance when building the node tree
    • How changes are applied
    • Attaching and drawing the nodes
    • Composition
    • Creating a Composition
    • The initial Composition process
    • Applying changes after initial Composition
    • Additional information about the Composition
    • The Recomposer
    • Spawning the Recomposer
    • Recomposition process
    • Concurrent recomposition
    • Recomposer states
  • 4. Compose UI
    • Integrating UI with the Compose runtime
    • Mapping scheduled changes to actual changes to the tree
    • Composition from the point of view of Compose UI
    • Subcomposition from the point of view of Compose UI
    • Reflecting changes in the UI
    • Different types of Appliers
    • Materializing a new LayoutNode
    • Closing the circle
    • Materializing a change to remove nodes
    • Materializing a change to move nodes
    • Materializing a change to clear all the nodes
    • Measuring in Compose UI
    • Measuring policies
    • Intrinsic measurements
    • Layout Constraints
    • LookaheadLayout
    • Modeling modifier chains
    • Setting modifiers to the LayoutNode
    • How LayoutNode ingests new modifiers
    • Drawing the node tree
    • Semantics in Jetpack Compose
    • Notifying about semantic changes
    • Merged and unmerged semantic trees
  • 5. State snapshot system
    • What snapshot state is
    • Concurrency control systems
    • Multiversion concurrency control (MCC or MVCC)
    • The Snapshot
    • The snapshot tree
    • Snapshots and threading
    • Observing reads and writes
    • MutableSnapshots
    • GlobalSnapshot and nested snapshots
    • StateObjects and StateRecords
    • Reading and writing state
    • Removing or reusing obsolete records
    • Change propagation
    • Merging write conflicts
  • 6. Effects and effect handlers
    • Introducing side effects
    • Side effects in Compose
    • What we need
    • Effect Handlers
    • Non suspended effects
    • Suspended effects
    • Third party library adapters
  • 7. Advanced Compose Runtime use cases
    • Compose runtime vs Compose UI
    • (Re-) Introducing composition
    • Composition of vector graphics
    • Building vector image tree
    • Integrating vector composition into Compose UI
    • Managing DOM with Compose
    • Standalone composition in the browser
    • Conclusion

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub