Skip to content

Core concepts

diklimchuk edited this page Apr 24, 2021 · 3 revisions

Here's a diagram with all interations happening a screen:

  • What is a State?

Complete app state. At every moment in time the completed screen state can be recreated by just the data stored in it. You must make exceptions if it complicates your screen logic. It might be unnecessary to persist whether an AlertDialog is displayed or what exact text is displayed in the EditText.

  • What is an Event?

All events that affect screen and actions on the screen. At Vivid.money, we separete all event to two types, Ui and Internal. This is useful for using ELM to model screen logic on android: Ui: Screen lifecycle, communicating with user, everything that comes from the View layer Internal: Results of bussiness logic operations. Don't worry, you don't have to, the library allows to choose your own path.

  • What is an Effect?

Single Live Event. Actions, that happen only once, like interacting with UI. Our implementation in elmslie-android restricts Effect handling only to the time when the screen is visible to the user.

Examples: navigation, dispalying a dialog, displaying an error.

  • What is a Command?

Each command represents one asynchronous interation, like communication with bussincess logic. The result of execution of a command is represented with Events which later affect state of a screen of some busseness logic feature.

  • What is a Reducer?

A Class, that contains (mostly) all screen(or feature) logic and just it. It should be implemented as a pure function, which based on a current screen State and a new Event calculates a new State, optional operatons that should be executed (named Commands) and optional one-off actions, Efects.

  • What is a Result?

The overall output on one Reducer operation. This is a simple wrapper around a new State, Commands and Effects

  • What is an Actor?

A class, that executes asynchronous operations. When used for a screen implementation may proxy calls rest api, subscribe to model changes or perform some long-running computations. It maps the result of execution to Events. It also can perorm some more complex operations, combining multiple request or map data.

  • What is a Store?

Each Store represents logic of work one feature or a screen. It dosn't handle anything related to screen lifecyle and is completely independent of the platform it's executed on. Whed used for implementing a screen it allows the View to subsribe to State changes for rendering and Effects for handling one-off operaations. Store is already implemented in the library, there's no need to create your own class for it. It only requires an Actor and Reducer implementations.

  • What is a StoreFactory

Class, that combines all working parts into a Store. It initializes the starting screen state, sets the appropriate Reducer and Actor.