• Stars
    star
    276
  • Rank 144,709 (Top 3 %)
  • Language
    Kotlin
  • License
    Other
  • Created over 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Showcase project of Functional Reactive Programming on Android, using RxJava.

FunctionalAndroidReference

FunctionalAndroidReference is a showcase project of Functional Reactive Programming on Android, using RxJava.

It's a companion app to the presentation "Fully Reactive Apps" at Droidcon UK 2016.

Build Status codecov

It is not meant to be a canonical reference, but as an example of how far functional programming can be taken. It's also a collection of patterns and ideas about how to express use cases, business features, and UX on a FRP paradigm.

The project has multiple self-imposed limitations:

Full separation between UI and business logic.

The project is split into several modules. Every module has its own README file.

app

The UI layer is written purely in Java 7 with Android dependencies.

It depends on all modules below.

liblogic

The business logic that controls the views. It doesn't contain any Android dependency.

It is written in Kotlin for convenience, but it could be rewritten in Java 7 with ease, although it will be a bit verbose without lambdas (see retrolambda).

It depends on the modules below.

libservices

Any network services, POJOs, and communications that aren't in the Android framework. Again, it's not dependent on any Android.

Written in Kotlin too.

It depends on the module below.

libcore

Helpers and common general types. No Android.

Written in Kotlin, with no Android dependencies.

Pragmatically functional

  • liblogic and libservices must contain as few classes as pragmatically possible. Favour functions instead.

  • Every function must be written as an expression body.

  • Every function must be as pure as possible.

  • Every parameter in a function must be passed explicitly. No globals, no fields.

  • Prefer encapsulating variables in closures rather than fields. If using fields, final fields will be mandated whenever possible.

  • Collections must be immutable.

  • No nullable types outside the UI and service layers.

  • Use functional patterns like unions, laziness, or higher order functions, instead of classic OOP Gang of Four patterns.

Fully reactive

The architecture is reminiscent of Flux, Redux, or Elm. This is no coincidence.

Every method in the UI layer is either:

  • a stream/signal, represented by a method returning an rx.Observable.

  • a new UI state: new text value, new element on a RecyclerView, show a dialog... represented by a void/Unit method.

Every function in the business layer is:

  • a rx.Subscription encompassing all the behaviour for one or many use cases.

Testable

Every use case must be accompanied of a test suite covering its complete behaviour.

Moderately documented

Every public function must be documented.

Inlined comments only when intent isn't clear.

No lifecycle

Separate the business logic from the Android lifecycle at the earliest layer possible.

No magic

Avoid DI frameworks like Dagger, and hand-roll injection instead.

Avoid code generation outside Kotlin helpers.

License

Copyright (c) pakoito 2016

The Apache Software License, Version 2.0

See LICENSE.md

More Repositories

1

MarI-O

Github clone of MarI/O by SethBling
224
star
2

RxSealedUnions

Compile-time checked Unions of different types for Domain Modeling [STABLE]
Java
127
star
3

Komprehensions

Do comprehensions for Kotlin and 3rd party libraries [STABLE]
Kotlin
114
star
4

RxTuples

Simple tuples to use with RxJava [STABLE]
Java
112
star
5

RxPaper2

NoSQL storage with RxJava2 bindings [STABLE]
Java
100
star
6

RxPaper

NoSQL storage with RxJava bindings [STABLE]
Java
88
star
7

RxComprehensions

Reduce boilerplate in RxJava by abstracting chained operators like flatMap, concatMap, switchMap, or compose [STABLE]
Java
86
star
8

RxObservableDiskCache

Simple NoSQL disk cache for network responses [STABLE]
Java
86
star
9

FunctionalRx2

FunctionalRx2 is a collection of constructs to simplify a functional programming approach to Java and Android [STABLE]
83
star
10

JavaSealedUnions

Tagged Unions for the Java 8 connoisseur
Java
54
star
11

SongkickInterview

App handed in as part of Songkick's interview process
Java
51
star
12

RxFunctions

Advanced Function composition to use with RxJava [STABLE]
Java
49
star
13

FunctionalRx

FunctionalRx is a collection of constructs to simplify a functional programming approach to Java and [STABLE]
48
star
14

RxCurrying

Simple currying for FuncN and ActionN on RxJava [STABLE]
Java
38
star
15

RxSealedUnions2

Compile-time checked Unions of different types for Domain Modeling [STABLE]
Java
35
star
16

RxActions

Simple ActionN composition to use with RxJava [STABLE]
Java
33
star
17

RxPartialApplication

Simple partial application for FuncN and ActionN on RxJava [STABLE]
Java
30
star
18

RustyAndroid

Interoping Android's Java with Rust via JNA
C
28
star
19

RxTuples2

Simple tuples to use with RxJava2 [STABLE]
Java
22
star
20

RxMemoization

Simple Function result caching for RxJava [STABLE]
Java
20
star
21

RxObservableDiskCache2

Simple NoSQL disk cache for network responses [STABLE]
Java
14
star
22

javafxmobile-plugin-ensemble

Git clone of JavaFX on iOS and Android
Java
8
star
23

ToME---t-engine4

Github fork of ToME/TE4
Lua
8
star
24

CardGameFramework

Prototype framework to create card games on the fly
Java
6
star
25

RxCurrying2

Simple currying for FunctionN and ConsumerN on RxJava2 [STABLE]
Java
5
star
26

RxErrorAlgebra

Java
4
star
27

ggwp

A port of GGPO (https://github.com/pond3r/ggpo) to Rust
Rust
4
star
28

printableheroes

JavaScript
3
star
29

DT3

DT3 Game Engine by Smells Like Donkey Software Inc.
C
3
star
30

DOT

The open source version of the DOT AI Engine.
C++
3
star
31

react-jus

A React Component for polyominos on a grid
2
star
32

RxFunctions2

Advanced Function composition to use with RxJava2 [STABLE]
Java
2
star
33

RxMemoization2

Simple Function result caching for RxJava [Stable]
Java
2
star
34

RxConsumers

Simple Consumer composition to use with RxJava [STABLE]
Java
2
star
35

RxPartialApplication2

Simple partial application for FuncN and ActionN on RxJava 2.X [STABLE]
Java
2
star
36

RxJava2Consumers

Copy of the missing Consumer interfaces in RxJava2 available in RxJava2Extensions [Stable]
Java
2
star
37

pnpcut

Q&D script to process cards in bulk to 3x3 A4
JavaScript
2
star
38

ludumdare31

Project for LD31
Java
1
star
39

Gameroom

Test room for github development
1
star
40

byuu

byuu is a multi-system emulator focused on performance, features, and ease of use.
1
star
41

buildmancer

A build theorycrafting boadgame you can play offline!
TypeScript
1
star
42

HexUtils

Some utilities for working with hexagons, mostly based on http://www.redblobgames.com/grids/hexagons/
Java
1
star
43

2DEngine

2d engine for iphone games
1
star