Leanpub Header

Skip to main content

Jetpack Compose internals

Jetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

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.

Price

Pick Your Price...

Minimum price

$34.99

$49.99

You pay

$49.99

Author earns

$39.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 3)

3
The author will earn $36.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Jorge Castillo

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

Translations

Translations

Languages

Translation Bundles

Contents

Table of Contents

Prelude

  1. Why to read this book
  2. What this book is not about
  3. Why to write about internals
  4. Keep the sources close
  5. Code snippets and examples

1. Composable functions

  1. The meaning of Composable functions
  2. Properties of Composable functions
  3. Calling context
  4. Idempotent
  5. Free of uncontrolled side effects
  6. Restartable
  7. Fast execution
  8. Positional memoization
  9. Similarities with suspend functions
  10. The color of Composable functions
  11. Composable function types

2. The Compose compiler

  1. A Kotlin compiler plugin
  2. Compose annotations
  3. Registering Compiler extensions
  4. Kotlin Compiler version
  5. Static analysis
  6. Static Checkers
  7. Call checks
  8. Type checks
  9. Declaration checks
  10. Diagnostic suppression
  11. Runtime version check
  12. Code generation
  13. The Kotlin IR
  14. Lowering
  15. Inferring class stability
  16. Enabling live literals
  17. Compose lambda memoization
  18. Injecting the Composer
  19. Comparison propagation
  20. Default parameters
  21. Control flow group generation
  22. Klib and decoy generation

3. The Compose runtime

  1. The slot table and the list of changes
  2. The slot table in depth
  3. The list of changes
  4. The Composer
  5. Feeding the Composer
  6. Modeling the Changes
  7. Optimizing when to write
  8. Writing and reading groups
  9. Remembering values
  10. Recompose scopes
  11. SideEffects in the Composer
  12. Storing CompositionLocals
  13. Storing source information
  14. Linking Compositions via CompositionContext
  15. Accessing the current State snapshot
  16. Navigating the nodes
  17. Keeping reader and writer in sync
  18. Applying the changes
  19. Performance when building the node tree
  20. How changes are applied
  21. Attaching and drawing the nodes
  22. Composition
  23. Creating a Composition
  24. The initial Composition process
  25. Applying changes after initial Composition
  26. Additional information about the Composition
  27. The Recomposer
  28. Spawning the Recomposer
  29. Recomposition process
  30. Concurrent recomposition
  31. Recomposer states

4. Compose UI

  1. Integrating UI with the Compose runtime
  2. Mapping scheduled changes to actual changes to the tree
  3. Composition from the point of view of Compose UI
  4. Subcomposition from the point of view of Compose UI
  5. Reflecting changes in the UI
  6. Different types of Appliers
  7. Materializing a new LayoutNode
  8. Closing the circle
  9. Materializing a change to remove nodes
  10. Materializing a change to move nodes
  11. Materializing a change to clear all the nodes
  12. Measuring in Compose UI
  13. Measuring policies
  14. Intrinsic measurements
  15. Layout Constraints
  16. LookaheadLayout
  17. Modeling modifier chains
  18. Setting modifiers to the LayoutNode
  19. How LayoutNode ingests new modifiers
  20. Drawing the node tree
  21. Semantics in Jetpack Compose
  22. Notifying about semantic changes
  23. Merged and unmerged semantic trees

5. State snapshot system

  1. What snapshot state is
  2. Concurrency control systems
  3. Multiversion concurrency control (MCC or MVCC)
  4. The Snapshot
  5. The snapshot tree
  6. Snapshots and threading
  7. Observing reads and writes
  8. MutableSnapshots
  9. GlobalSnapshot and nested snapshots
  10. StateObjects and StateRecords
  11. Reading and writing state
  12. Removing or reusing obsolete records
  13. Change propagation
  14. Merging write conflicts

6. Effects and effect handlers

  1. Introducing side effects
  2. Side effects in Compose
  3. What we need
  4. Effect Handlers
  5. Non suspended effects
  6. Suspended effects
  7. Third party library adapters

7. Advanced Compose Runtime use cases

  1. Compose runtime vs Compose UI
  2. (Re-) Introducing composition
  3. Composition of vector graphics
  4. Building vector image tree
  5. Integrating vector composition into Compose UI
  6. Managing DOM with Compose
  7. Standalone composition in the browser
  8. Conclusion

Contributor

About the Contributors

Andrei Shikov

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.

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...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

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

In fact, authors have earned over $14 million writing, 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