SShortSingh.
Back to feed

Android app architecture: ViewModel, unidirectional data flow and modules

0
·7 views

A common failure is a screen ViewModel that gradually absorbs date formatting, retry logic and conflicting boolean flags until it is hard to reason about. The article proposes a simple set of rules that stay workable after release, with each screen described by one immutable UI state exposed as a StateFlow. User actions are sent up as plain ViewModel function calls, while data access sits behind a repository that the ViewModel never sees the network or database types of. Unidirectional data flow keeps state changes in a single place, so bugs such as a spinner that never stops can be traced to one class. The example is an expense list split across four Gradle modules, and the author notes that modularisation is only worth doing once build time or team boundaries demand it.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingHacker News ·

YouTube Ad Punisher project on GitHub aims to bypass anti-adblock measures

A GitHub project called YouTube Ad Punisher has been shared on Hacker News, drawing 16 points and 5 comments. The tool is described as a way to get around YouTube's anti-adblock detection. The source material provides only the project link and discussion metadata, so details about its methods and functionality are not available. The item reflects ongoing community interest in ad-blocking workarounds on the platform.

0
ProgrammingHacker News ·

Site Launched to Track Diseases Reportedly Cured by AI

A new website called Diseases Cured by AI has been shared on Hacker News, where it drew 26 points and 6 comments. The site appears to compile and track claims of diseases that artificial intelligence has helped cure. The original post provides only the link and discussion metrics, without a detailed description of the site's contents or methodology. Readers would need to visit the site directly to evaluate the specific claims it presents.

0
ProgrammingHacker News ·

AMD Releases Llama.cpp Patches Targeting Its Hardware

A post on devnull.land highlights a set of AMD-specific patches for llama.cpp, the open-source project for running large language models locally. The patches are aimed at improving compatibility and performance on AMD hardware. The item was shared on Hacker News, where it drew 50 points and 8 comments. The source text provides only a brief summary, so details about the specific changes, their performance impact, and their official status are not available.

0
ProgrammingDEV Community ·

Quiet Watch Winder Build Focuses on Motor Choice and Resonance Control

A DIY builder who makes things professionally describes designing a quiet automatic watch winder after noticing noise problems. The article identifies three noise sources: motor and gearbox whine, enclosure resonance that amplifies vibration, and impulse clicks from abrupt starts and stops. Recommended fixes include choosing a worm-drive or brushless motor, decoupling the motor with damping material, adding mass to the cup, and programming soft start and stop ramps. The author also notes that winding direction and turns per day must match the movement, and that intermittent rest periods are better for both the watch and the winder.